MythDialog* ChannelGroupEditor::dialogWidget(MythMainWindow* parent, const char* widgetName) { dialog = ConfigurationDialog::dialogWidget(parent, widgetName); connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(doDelete())); connect(dialog, SIGNAL(deleteButtonPressed()), this, SLOT(doDelete())); return dialog; }
MythDialog *MythGamePlayerEditor::dialogWidget(MythMainWindow *parent, const char *widgetName) { dialog = ConfigurationDialog::dialogWidget(parent, widgetName); connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(menu())); connect(dialog, SIGNAL(editButtonPressed()), this, SLOT(edit())); connect(dialog, SIGNAL(deleteButtonPressed()), this, SLOT(del())); return dialog; }
void newGameMenu::MouseButtonDown(int Button, Vector2 Location) { MouseMotion(Location); for(int a = 0; a < 3; a++) { if((abs(difficultyIcons[a].location.x - Location.x) < 32) && (abs(difficultyIcons[a].location.y - Location.y) < 32)) { selectedDifficulty = a; selectedMenuItem = -1; break; } } if(selectedMenuItem > -1) menuButtonPressed(); ToggleDifficultyButtons(); };
DialogCode ProfileGroupEditor::exec(void) { DialogCode ret = kDialogCodeAccepted; redraw = true; while ((QDialog::Accepted == ret) || redraw) { redraw = false; Load(); dialog = new ConfigurationDialogWidget(GetMythMainWindow(), "ProfileGroupEditor"); connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(callDelete())); int width = 0, height = 0; float wmult = 0.0f, hmult = 0.0f; GetMythUI()->GetScreenSettings(width, wmult, height, hmult); QVBoxLayout *layout = new QVBoxLayout(dialog); layout->setMargin((int)(20 * hmult)); layout->addWidget(listbox->configWidget(NULL, dialog)); dialog->Show(); ret = dialog->exec(); dialog->deleteLater(); dialog = NULL; if (ret == QDialog::Accepted) open(listbox->getValue().toInt()); } return kDialogCodeRejected; }
/** Adds the buttons for one side of the title bar, based on the spec * string; see the KWinInternal::KDecoration class, methods * titleButtonsLeft and titleBUttonsRight. */ void NextClient::addButtons(QBoxLayout* titleLayout, const QString& spec) { for (unsigned int i=0; i<spec.length(); i++) { switch (spec[i].latin1()) { case 'A': if (isMaximizable()) { button[MAXIMIZE_IDX] = new NextButton(this, "maximize", maximize_bits, 10, 10, i18n("Maximize"), LeftButton|MidButton|RightButton); titleLayout->addWidget( button[MAXIMIZE_IDX] ); connect( button[MAXIMIZE_IDX], SIGNAL(clicked()), this, SLOT(maximizeButtonClicked()) ); } break; case 'H': if (providesContextHelp()) { button[HELP_IDX] = new NextButton(this, "help", question_bits, 10, 10, i18n("Help")); titleLayout->addWidget( button[HELP_IDX] ); connect( button[HELP_IDX], SIGNAL(clicked()), this, SLOT(showContextHelp()) ); } break; case 'I': if (isMinimizable()) { button[ICONIFY_IDX] = new NextButton(this, "iconify", iconify_bits, 10, 10, i18n("Minimize")); titleLayout->addWidget( button[ICONIFY_IDX] ); connect( button[ICONIFY_IDX], SIGNAL(clicked()), this, SLOT(minimize()) ); } break; case 'M': button[MENU_IDX] = new NextButton(this, "menu", NULL, 10, 10, i18n("Menu"), LeftButton|RightButton); titleLayout->addWidget( button[MENU_IDX] ); // NOTE DIFFERENCE: capture pressed(), not clicked() connect( button[MENU_IDX], SIGNAL(pressed()), this, SLOT(menuButtonPressed()) ); break; case 'L': button[SHADE_IDX] = new NextButton(this, "shade", NULL, 0, 0, i18n("Shade")); titleLayout->addWidget( button[SHADE_IDX] ); connect( button[SHADE_IDX], SIGNAL(clicked()), this, SLOT(shadeClicked()) ); // NOTE DIFFERENCE: set the pixmap separately (2 states) shadeChange(); break; case 'S': button[STICKY_IDX] = new NextButton(this, "sticky", NULL, 0, 0, i18n("On all desktops")); titleLayout->addWidget( button[STICKY_IDX] ); connect( button[STICKY_IDX], SIGNAL(clicked()), this, SLOT(toggleOnAllDesktops()) ); // NOTE DIFFERENCE: set the pixmap separately (2 states) desktopChange(); break; case 'F': button[ABOVE_IDX] = new NextButton(this, "above", NULL, 0, 0, ""); titleLayout->addWidget( button[ABOVE_IDX] ); connect( button[ABOVE_IDX], SIGNAL(clicked()), this, SLOT(aboveClicked()) ); connect(this, SIGNAL(keepAboveChanged(bool)), SLOT(keepAboveChange(bool))); keepAboveChange(keepAbove()); break; case 'B': button[BELOW_IDX] = new NextButton(this, "below", NULL, 0, 0, ""); titleLayout->addWidget( button[BELOW_IDX] ); connect( button[BELOW_IDX], SIGNAL(clicked()), this, SLOT(belowClicked()) ); connect(this, SIGNAL(keepBelowChanged(bool)), SLOT(keepBelowChange(bool))); keepBelowChange(keepBelow()); break; case 'X': if (isCloseable()) { button[CLOSE_IDX] = new NextButton(this, "close", close_bits, 10, 10, i18n("Close")); titleLayout->addWidget(button[CLOSE_IDX]); connect(button[CLOSE_IDX], SIGNAL(clicked()), this, SLOT(closeWindow())); } break; case 'R': if (mustDrawHandle()) { button[RESIZE_IDX] = new NextButton(this, "resize", resize_bits, 10, 10, i18n("Resize")); titleLayout->addWidget(button[RESIZE_IDX]); // NOTE DIFFERENCE: capture pressed(), not clicked() connect(button[RESIZE_IDX], SIGNAL(pressed()), this, SLOT(resizePressed())); } break; case '_': // TODO: Add spacer handling break; default: kdDebug() << " Can't happen: unknown button code " << QString(spec[i]); break; } } }
int main(void) { initRTC(); initControls(); initLCD(); initValve(); // timer0 is being used as a global 'heartbeat' // i.e. for blinking in the LCD // and for running a temperature check at regular intervals TCCR0A = (1<<CS02)|(1<<CS00); // timer clock = system clock / 1024 TIFR0 = (1<<TOV0); // clear pending interrupts TIMSK0 = (1<<TOIE0); // enable timer0 overflow Interrupt sei(); // Enable Global Interrupts // start a probe run to find the "fully open" and "fully closed" positions doProbe(); // initialize the NTC sensor and start the 1st measurement // consequent measurements will be done every tick initTemp(); runstate = NORMAL_STATE; while (1) { if( adcTemp < targetTemp && valvestate != VALVE_OPEN ) { openValve(); } else if( valvestate != VALVE_CLOSED ) { closeValve(); } if( menuButtonPressed() ) { switch( runstate ) { case NORMAL_STATE : runstate = MENU_STATE; break; default : runstate = NORMAL_STATE; break; } } // end if( menuButtonPressed ) if( timeButtonPressed() ) { switch( runstate ) { case NORMAL_STATE : runstate = TIMESET_STATE; timesetphase = TIMESET_START; _delay_ms( 500 ); // show time with hours blinking timesetphase = TIMESET_YEAR; break; default : runstate = NORMAL_STATE; break; } } // end if( timeButtonPressed ) if( okButtonPressed() ) { switch( runstate ) { case MENU_STATE : switch( mainmenu ) { case TEMP : runstate = TEMPSET_STATE; break; case TIME : runstate = TIMESET_STATE; timesetphase = TIMESET_START; _delay_ms( 500 ); // show time with hours blinking timesetphase = TIMESET_YEAR; break; default: break; } break; case TEMPSET_STATE : runstate = MENU_STATE; break; case TIMESET_STATE : switch( timesetphase ) { case TIMESET_YEAR : timesetphase = TIMESET_MONTH; break; case TIMESET_MONTH : timesetphase = TIMESET_DATE; break; case TIMESET_DATE : timesetphase = TIMESET_HOURS; break; case TIMESET_HOURS : timesetphase = TIMESET_MINUTES; break; case TIMESET_MINUTES : timesetphase = TIMESET_YEAR; break; default : break; } break; default : break; } } // end if( okButtonPressed ) ROTARYBUTTON rotaryButton = readRotaryButton(); if( rotaryButton == ROTARY_UP ) { switch( runstate ) { case NORMAL_STATE : case MENU_STATE : mainmenu++; if( mainmenu == LAST_ITEM ) mainmenu = 0; break; case TIMESET_STATE : increaseClock( timesetphase ); break; case TEMPSET_STATE : if( targetTemp >= 500 ) targetTemp = 0; else targetTemp += 5; break; default : break; } } // end if( BUTTON_UP_PRESSED ) if( rotaryButton == ROTARY_DOWN ) { switch( runstate ) { case NORMAL_STATE : case MENU_STATE : if( mainmenu == 0 ) mainmenu = LAST_ITEM; mainmenu--; break; case TIMESET_STATE : decreaseClock( timesetphase ); break; case TEMPSET_STATE : if( targetTemp == 0 ) targetTemp = MAXTEMP; else targetTemp -= 5; break; default : break; } } // end if( BUTTON_DOWN_PRESSED ) // go to sleep but wake up if any button is pressed set_sleep_mode( SLEEP_MODE_ADC ); sleep_mode(); } // end while forever }
bool AppletHandle::eventFilter(QObject *o, QEvent *e) { if (o == parent()) { switch (e->type()) { case QEvent::Enter: { m_drawHandle = true; resetLayout(); if (m_handleHoverTimer) { m_handleHoverTimer->start(250); } break; } case QEvent::Leave: { if (m_menuButton && m_menuButton->isOn()) { break; } QWidget* w = dynamic_cast<QWidget*>(o); bool nowDrawIt = false; if (w) { // a hack for applets that have out-of-process // elements (e.g the systray) so that the handle // doesn't flicker when moving over those elements if (w->rect().contains(w->mapFromGlobal(QCursor::pos()))) { nowDrawIt = true; } } if (nowDrawIt != m_drawHandle) { if (m_handleHoverTimer) { m_handleHoverTimer->stop(); } m_drawHandle = nowDrawIt; resetLayout(); } break; } default: break; } return QWidget::eventFilter( o, e ); } else if (o == m_dragBar) { if (e->type() == QEvent::MouseButtonPress) { QMouseEvent* ev = static_cast<QMouseEvent*>(e); if (ev->button() == LeftButton || ev->button() == MidButton) { emit moveApplet(m_applet->mapFromGlobal(ev->globalPos())); } } } if (m_menuButton && e->type() == QEvent::MouseButtonPress) { QMouseEvent* ev = static_cast<QMouseEvent*>(e); if (ev->button() == RightButton) { if (!m_menuButton->isDown()) { m_menuButton->setDown(true); menuButtonPressed(); } return true; } } return QWidget::eventFilter(o, e); // standard event processing }
void KCommonDecoration::addButtons(ButtonContainer &btnContainer, const QString& s, bool isLeft) { if (s.length() > 0) { for (unsigned n=0; n < s.length(); n++) { KCommonDecorationButton *btn = 0; switch (s[n]) { case 'M': // Menu button if (!m_button[MenuButton]){ btn = createButton(MenuButton); if (!btn) break; btn->setTipText(i18n("Menu") ); btn->setRealizeButtons(LeftButton|RightButton); connect(btn, SIGNAL(pressed()), SLOT(menuButtonPressed())); connect(btn, SIGNAL(released()), this, SLOT(menuButtonReleased())); m_button[MenuButton] = btn; } break; case 'S': // OnAllDesktops button if (!m_button[OnAllDesktopsButton]){ btn = createButton(OnAllDesktopsButton); if (!btn) break; const bool oad = isOnAllDesktops(); btn->setTipText(oad?i18n("Not on all desktops"):i18n("On all desktops") ); btn->setToggleButton(true); btn->setOn( oad ); connect(btn, SIGNAL(clicked()), SLOT(toggleOnAllDesktops())); m_button[OnAllDesktopsButton] = btn; } break; case 'H': // Help button if ((!m_button[HelpButton]) && providesContextHelp()){ btn = createButton(HelpButton); if (!btn) break; btn->setTipText(i18n("Help") ); connect(btn, SIGNAL(clicked()), SLOT(showContextHelp())); m_button[HelpButton] = btn; } break; case 'I': // Minimize button if ((!m_button[MinButton]) && isMinimizable()){ btn = createButton(MinButton); if (!btn) break; btn->setTipText(i18n("Minimize") ); connect(btn, SIGNAL(clicked()), SLOT(minimize())); m_button[MinButton] = btn; } break; case 'A': // Maximize button if ((!m_button[MaxButton]) && isMaximizable()){ btn = createButton(MaxButton); if (!btn) break; btn->setRealizeButtons(LeftButton|MidButton|RightButton); const bool max = maximizeMode()==MaximizeFull; btn->setTipText(max?i18n("Restore"):i18n("Maximize") ); btn->setToggleButton(true); btn->setOn( max ); connect(btn, SIGNAL(clicked()), SLOT(slotMaximize())); m_button[MaxButton] = btn; } break; case 'X': // Close button if ((!m_button[CloseButton]) && isCloseable()){ btn = createButton(CloseButton); if (!btn) break; btn->setTipText(i18n("Close") ); connect(btn, SIGNAL(clicked()), SLOT(closeWindow())); m_button[CloseButton] = btn; } break; case 'F': // AboveButton button if (!m_button[AboveButton]){ btn = createButton(AboveButton); if (!btn) break; bool above = keepAbove(); btn->setTipText(above?i18n("Do not keep above others"):i18n("Keep above others") ); btn->setToggleButton(true); btn->setOn( above ); connect(btn, SIGNAL(clicked()), SLOT(slotKeepAbove())); m_button[AboveButton] = btn; } break; case 'B': // BelowButton button if (!m_button[BelowButton]){ btn = createButton(BelowButton); if (!btn) break; bool below = keepBelow(); btn->setTipText(below?i18n("Do not keep below others"):i18n("Keep below others") ); btn->setToggleButton(true); btn->setOn( below ); connect(btn, SIGNAL(clicked()), SLOT(slotKeepBelow())); m_button[BelowButton] = btn; } break; case 'L': // Shade button if ((!m_button[ShadeButton]) && isShadeable()){ btn = createButton(ShadeButton); if (!btn) break; bool shaded = isSetShade(); btn->setTipText(shaded?i18n("Unshade"):i18n("Shade") ); btn->setToggleButton(true); btn->setOn( shaded ); connect(btn, SIGNAL(clicked()), SLOT(slotShade())); m_button[ShadeButton] = btn; } break; case '_': // Spacer item btnContainer.append(0); } if (btn) { btn->setLeft(isLeft); btn->setSize(QSize(layoutMetric(LM_ButtonWidth, true, btn),layoutMetric(LM_ButtonHeight, true, btn)) ); btn->show(); btnContainer.append(btn); } } } }