📄 qtguimainwindow.cpp
字号:
}voidQtGUIMainWindow::volumeMicChanged (int val) { _callmanager->setMicroVolume(val);}voidQtGUIMainWindow::registerSlot (void) { _panel->saveSlot(); registerVoIPLink();}/** * Slot to blink with free and busy pixmaps when line is hold. */voidQtGUIMainWindow::blinkLineSlot (void) { static bool isOn = false; int state = BUSY; if (!isOn) { state = FREE; } for (int i = 0; i < NUMBER_OF_LINES; i++) { // If lines are hold on, set blinking pixmap if (phLines[i]->isOnHold()) { phLines[i]->button()->setPixmap(TabLinePixmap[i][state]); } } isOn = !isOn;}// Dial the voicemail Number automatically when button is clickedvoidQtGUIMainWindow::button_msg (void) { stopTimerMessage(); _lcd->appendText(get_config_fields_str(PREFERENCES, VOICEMAIL_NUM)); qt_outgoingCall();}// Allow to enter a phone number to transfer the current call.// This number is validated by ok-button or typing EntervoidQtGUIMainWindow::button_transfer (void) { if (getCurrentLine() != -1) { setTransfer(true); onHoldCall(line2id(getCurrentLine())); displayStatus(TRANSFER_STATUS); }}voidQtGUIMainWindow::button_conf (void) {//TODO: This feature is not implemented yet QMessageBox::information(this, "Conference", "This feature is not implemented yet", QMessageBox::Yes);}voidQtGUIMainWindow::button_line0 (void) { toggleLine (0); }voidQtGUIMainWindow::button_line1 (void) { toggleLine (1);}voidQtGUIMainWindow::button_line2 (void) { toggleLine (2);}voidQtGUIMainWindow::button_line3 (void) { toggleLine (3);}voidQtGUIMainWindow::button_line4 (void) { toggleLine (4);}voidQtGUIMainWindow::button_line5 (void) { toggleLine (5);}voidQtGUIMainWindow::button_mute(void) { // Disable micro sound static bool isOn = true; int id = line2id(getCurrentLine()); if (_callmanager->getNumberOfCalls() > 0) { // If there is at least a pending call if(!isOn) { qt_muteOff(id); } else { qt_muteOn(id); } isOn = !isOn; }}// Show the setup _panelvoidQtGUIMainWindow::configuration (void) { _panel->show();}voidQtGUIMainWindow::addressBook (void) { QMessageBox::information(this, "Directory", "This feature is not implemented yet", QMessageBox::Yes);}// Handle the dtmf-button clickvoidQtGUIMainWindow::dtmfKeypad (void) { if (_keypad->isVisible()) { // Hide _keypad if it's visible. _keypad->hide(); } else { if (_first and !getMoved()) { // If it's the first time that _keypad is shown. // The position is fixed with the main initial position. _first = false; _keypad->setGeometry (MAIN_INITIAL_POSITION + this->getSourceImage().width(), MAIN_INITIAL_POSITION, _keypad->getSourceImage().width(), _keypad->getSourceImage().height()); } else { // If main window is moved, we calculate the _keypad new position // to fix it with main window if (getMoved()) { _keypad->setGeometry (positionOffsetX(), getGlobalMouseY() - getMouseY(), _keypad->getSourceImage().width(), _keypad->getSourceImage().height()); } if (_keypad->getMoved()) { // If _keypad is moved, it shows at the previous position _keypad->setGeometry ( _keypad->getGlobalMouseX()-_keypad->getMouseX(), _keypad->getGlobalMouseY()-_keypad->getMouseY(), _keypad->getSourceImage().width(), _keypad->getSourceImage().height()); } } // Show _keypad if it's hidden. _keypad->show(); }}// Get x-position offset, related to the screen size, to show numeric _keypadintQtGUIMainWindow::positionOffsetX (void) { QRect screenRect; int offset; // Get the screen geometry screenRect = (QApplication::desktop())->screenGeometry (0); offset = this->getSourceImage().width() - getMouseX() + getGlobalMouseX(); if (offset + _keypad->getSourceImage().width() > screenRect.right()) { return getGlobalMouseX() - ( getMouseX() + _keypad->getSourceImage().width()); } else { return offset; }}/** * Slot when receive a message, blink pixmap. */voidQtGUIMainWindow::blinkMessageSlot (void) { static bool isOn = false; int stateMsg = BUSY; if(!isOn) { stateMsg = FREE; } if (_msgVar) { phoneKey_msg->setPixmap(TabMsgPixmap[stateMsg]); } isOn = !isOn;}/** * Slot when phone is ringing, blink pixmap. */voidQtGUIMainWindow::blinkRingSlot (void) { static bool isOn = false; int state = BUSY; int i; if (isThereIncomingCall() != -1) { // For the line if (!isOn) { state = FREE; } for (i = 0; i < NUMBER_OF_LINES; i++) { if (isIncomingCall(i) != -1 and phLines[i]->getbRinging()) { phLines[i]->button()->setPixmap(TabLinePixmap[i][state]); } } isOn = !isOn; }}/** * Slot to quit application with or without QMessageBox confirmation */voidQtGUIMainWindow::qt_quitApplication (void) { // Save volume positions // TODO: save position if direction is horizontal Config::set("Audio", "Volume.speakers_x", pt->getX(VOL_SPKR)); if (vol_spkr->getValue() != 0) { Config::set("Audio", "Volume.speakers_y", pt->getY(VOL_SPKR) - vol_spkr->getValue()); } Config::set("Audio", "Volume.micro_x", pt->getX(VOL_MIC)); if (vol_mic->getValue() != 0) { Config::set("Audio", "Volume.micro_y", pt->getY(VOL_MIC) - vol_mic->getValue()); } // Save current position of the controls volume save(); if (get_config_fields_int(PREFERENCES, CONFIRM_QUIT) == YES) { // If message-box if (QMessageBox::question(this, "Confirm quit", "Are you sure you want to quit SFLPhone ?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { QApplication::exit(0); if (!quitApplication()) { _debug("Your data didn't be saved\n"); } } } else { // If no message-box QApplication::exit(0); if (!quitApplication()) { _debug("Your data didn't be saved\n"); } }}/** * Slot to strip _urlinput. */voidQtGUIMainWindow::stripSlot (void) { QRegExp rx(REG_EXPR); _lcd->appendText(_urlinput->url->text().remove(rx)); _urlinput->close();}/** * Slot when numeric _keypad phonekey is pressed, append the key text and setup * the DTMF _keypad . * * @param button group id */ voidQtGUIMainWindow::pressedKeySlot (int id) { char code = 0; int pulselen = 0; int callid; float32* tmp_urg_data; float32* buf_ctrl_vol; // Stop dial tone if (_dialtone) { dialtone(false); } switch (id) { case KEYPAD_ID_0: code = '0'; break; case KEYPAD_ID_1: code = '1'; break; case KEYPAD_ID_2: code = '2'; break; case KEYPAD_ID_3: code = '3'; break; case KEYPAD_ID_4: code = '4'; break; case KEYPAD_ID_5: code = '5'; break; case KEYPAD_ID_6: code = '6'; break; case KEYPAD_ID_7: code = '7'; break; case KEYPAD_ID_8: code = '8'; break; case KEYPAD_ID_9: code = '9'; break; case KEYPAD_ID_STAR: code = '*'; break; case KEYPAD_ID_HASH: code = '#'; break; } callid = line2id(getCurrentLine()); if (callid != -1 and getCall(callid)->isBusy()) { sendDtmf(callid, code); // pour envoyer DTMF } else { _lcd->appendText (code); } // Handle dtmf _key->startTone(code); _key->generateDTMF(_buf, SAMPLING_RATE); pulselen = get_config_fields_int(SIGNALISATION, PULSE_LENGTH); int size = pulselen * (OCTETS/1000); // Control volume buf_ctrl_vol = new float32[size]; for (int j = 0; j < size; j++) { buf_ctrl_vol[j] = _buf[j] * _callmanager->getSpkrVolume()/100; } // Free urg_data pointer tmp_urg_data = _callmanager->getAudioDriver()->mydata.urg_data; if (tmp_urg_data != NULL) { free (tmp_urg_data); } // Init struct mydata tmp_urg_data = buf_ctrl_vol; _callmanager->getAudioDriver()->mydata.urg_ptr = tmp_urg_data; _callmanager->getAudioDriver()->mydata.urg_remain = size; _callmanager->getAudioDriver()->startStream(); _callmanager->getAudioDriver()->sleep(pulselen); _callmanager->getAudioDriver()->stopStream(); _callmanager->getAudioDriver()->mydata.urg_remain = 0; delete[] buf_ctrl_vol;}// Save settings in config-filevoid QtGUIMainWindow::save() { saveConfig();}voidQtGUIMainWindow::applySkin (void) { _apply = true; // For skin of the screen _lcd->initGraphics(); setMainLCD(); // For skin of the gui initSkin();}// Handle operation to minimize the applicationvoid QtGUIMainWindow::reduceHandle (void) { if (get_config_fields_int(PREFERENCES, CHECKED_TRAY)) { clickHandle(); } else { showMinimized(); }}// Handle mouse left-button click to minimize/maximize the applicationvoidQtGUIMainWindow::clickHandle (void) { if (this->isShown()) { hide(); } else if (this->isMinimized()) { showMaximized(); } else { show(); }}voidQtGUIMainWindow::pressedKey0 (void) { pressedKeySlot (KEYPAD_ID_0);}voidQtGUIMainWindow::pressedKey1 (void) { pressedKeySlot (KEYPAD_ID_1);}voidQtGUIMainWindow::pressedKey2 (void) { pressedKeySlot (KEYPAD_ID_2);}voidQtGUIMainWindow::pressedKey3 (void) { pressedKeySlot (KEYPAD_ID_3);}voidQtGUIMainWindow::pressedKey4 (void) { pressedKeySlot (KEYPAD_ID_4);}voidQtGUIMainWindow::pressedKey5 (void) { pressedKeySlot (KEYPAD_ID_5);}voidQtGUIMainWindow::pressedKey6 (void) { pressedKeySlot (KEYPAD_ID_6);}voidQtGUIMainWindow::pressedKey7 (void) { pressedKeySlot (KEYPAD_ID_7);}voidQtGUIMainWindow::pressedKey8 (void) { pressedKeySlot (KEYPAD_ID_8);}voidQtGUIMainWindow::pressedKey9 (void) { pressedKeySlot (KEYPAD_ID_9);}voidQtGUIMainWindow::pressedKeyStar (void) { pressedKeySlot (KEYPAD_ID_STAR);}voidQtGUIMainWindow::pressedKeyHash (void) { pressedKeySlot (KEYPAD_ID_HASH);}///////////////////////////////////////////////////////////////////////////////// Protected Methods implementations //////////////////////////////////////////////////////////////////////////////////** * Reimplementation of keyPressEvent() to handle the keyboard mapping. */voidQtGUIMainWindow::keyPressEvent(QKeyEvent *e) { // Misc. key switch (e->key()) { case Qt::Key_At: case Qt::Key_Colon: case Qt::Key_Period: case Qt::Key_Comma: case Qt::Key_Plus: case Qt::Key_Minus: case Qt::Key_Slash: _lcd->appendText(QChar(e->key())); return; break; case Qt::Key_Backspace: _lcd->backspace(); return; break; case Qt::Key_Escape: hangupLine(); return; break; case Qt::Key_Return: case Qt::Key_Enter: dial(); return; break; case Qt::Key_F1: case Qt::Key_F2: case Qt::Key_F3: case Qt::Key_F4: case Qt::Key_F5: case Qt::Key_F6: this->toggleLine(e->key() - Qt::Key_F1); return; break; case Qt::Key_L: if (e->state() == Qt::ControlButton ) { _lcd->clear(); return; } break; case Qt::Key_Q : if (e->state() == Qt::ControlButton ) { emit keyPressed(e->key()); return; } break; case Qt::Key_O : if (e->state() == Qt::ControlButton ) { _urlinput->show(); return; } break; case Qt::Key_C : if (e->state() == Qt::ControlButton ) { configuration(); return; } break; case Qt::Key_D : if (e->state() == Qt::ControlButton ) { dtmfKeypad(); return; } break; case Qt::Key_Space: if (this->isInNumMode()) { this->setMode(TEXT_MODE); } else { this->setMode(NUM_MODE); } return; break; case Qt::Key_Alt: case Qt::Key_CapsLock: case Qt::Key_Shift: case Qt::Key_Tab: case Qt::Key_Control: return; break; default: break; } if (QChar(e->key()).isDigit() ) { // Numeric _keypad if (e->key() == Qt::Key_0) { pressedKeySlot(KEYPAD_ID_0); } else { pressedKeySlot(e->key() - Qt::Key_0 - 1); } } // Handle * and # too. else if ((e->key() == Qt::Key_Asterisk) or (e->key() == Qt::Key_NumberSign)) { (e->key() == Qt::Key_Asterisk) ? pressedKeySlot(KEYPAD_ID_STAR) : pressedKeySlot(KEYPAD_ID_HASH); } // If letter _keypad and numeric mode, display digit. else if (QChar(e->key()).isLetter() && this->isInNumMode() ) { pressedKeySlot( (NumericKeypadTools::keyToNumber(e->key())- Qt::Key_0) - 1); } // If letter _keypad and text mode, display letter. else if (QChar(e->key()).isLetter() && this->isInTextMode()) { _lcd->appendText(QChar(e->key()).lower()); } }#include "qtGUImainwindowmoc.cpp"// EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -