📄 qmminibuffer.cpp
字号:
/* ;-*-c++-*- * * qmminibuffer.cpp * * $Id: qmminibuffer.cpp,v 1.11.2.1 2002/10/10 21:40:52 kyllingstad Exp $ * * Apollo sound player: http://www.apolloplayer.org * Copyright(C) 2000-2002 Apollo Team. See CREDITS file. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * The GNU General Public License is also available online at: * * http://www.gnu.org/copyleft/gpl.html *//*! \file qmminibuffer.cpp Definition of QmMiniBuffer which provides a statusbar and search functionality.*//*! \class QmMiniBuffer qmminibuffer.h \brief Echo area/mini buffer*/#include "qmminibuffer.h"#include "qmmainwindow.h"#include "qmplaylistitem.h"#include <qapplication.h>#include <qlabel.h>#include <qlayout.h>#include <qlineedit.h>#include <qprogressbar.h>#include <qwidgetstack.h>QmMiniBuffer::QmMiniBuffer( QmMainWindow *parent) : QToolBar(parent), m_pHadFocus(0){ m_pStack = new QWidgetStack(this); m_pMessage = new QLabel(tr("Ready?"), m_pStack); m_pStack->addWidget(m_pMessage, 0); m_pSearch = new QWidget(m_pStack); QHBoxLayout *box = new QHBoxLayout(m_pSearch, 2); QLabel *l = new QLabel(tr("Search:"), m_pSearch); m_pField = new QmLineEdit(this, m_pSearch); connect(m_pField, SIGNAL(textChanged(const QString&)), this, SIGNAL(search(const QString&))); connect(m_pField, SIGNAL(returnPressed()), this, SLOT(returnPressed())); box->addWidget(l); box->addWidget(m_pField, 2); m_pStack->addWidget(m_pSearch, 1); m_pProgress = new QWidget(m_pStack); QHBoxLayout *box2 = new QHBoxLayout(m_pProgress, 2); QLabel *l2 = new QLabel(m_pProgress); m_pProgressBar = new QProgressBar(m_pProgress); box2->addWidget(l2, 2); box2->addWidget(m_pProgressBar); m_pStack->addWidget(m_pProgress, 2); m_pStack->raiseWidget(m_pMessage);}QmMiniBuffer::~QmMiniBuffer(){}/*! Shows the search field.*/voidQmMiniBuffer::activateSearch(){ m_pHadFocus = qApp->focusWidget(); m_pField->selectAll(); m_pStack->raiseWidget(m_pSearch); m_pField->setFocus();}/*! Hides the search field.*/voidQmMiniBuffer::deactivateSearch(){ m_pStack->raiseWidget(m_pMessage); m_pField->clearFocus(); if(m_pHadFocus) m_pHadFocus->setFocus(); QmPlayListItem::setMatchItem(0);}/*! Emits the search string again (next match). */voidQmMiniBuffer::returnPressed(){ // The signature of the signal is search(const QString&), while QLineEdit::text() // returns a QString object (not a reference). Still, this works: emit search(m_pField->text());}/*! Shows the message \a msg.*/voidQmMiniBuffer::message( const QString &msg, int /*msec*/ ){ m_pMessage->setText(msg);}/*! Clears the message field.*/voidQmMiniBuffer::clear(){ m_pMessage->clear();}QmMiniBuffer::QmLineEdit::QmLineEdit(QmMiniBuffer *buf, QWidget *parent, const char *name) : QLineEdit(parent, name), m_pBuf(buf){}voidQmMiniBuffer::QmLineEdit::keyPressEvent (QKeyEvent * e){ if ( (e->key()==Key_G && e->state()==ControlButton) || (e->key()==Key_Escape)) m_pBuf->deactivateSearch(); else QLineEdit::keyPressEvent(e);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -