mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: misc cleanups
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0041788b7f
commit
05dd897b78
14 changed files with 129 additions and 210 deletions
|
@ -92,7 +92,7 @@ void KAboutApplicationDialog::Private::init( const KAboutData *ad, Options opt )
|
|||
return;
|
||||
}
|
||||
|
||||
q->setPlainCaption(i18n("About %1", aboutData->programName()));
|
||||
q->setWindowTitle(i18n("About %1", aboutData->programName()));
|
||||
q->setButtons(KDialog::Close);
|
||||
q->setDefaultButton(KDialog::Close);
|
||||
q->setModal(false);
|
||||
|
|
|
@ -39,7 +39,7 @@ KAboutKdeDialog::KAboutKdeDialog(QWidget *parent)
|
|||
: KDialog(parent),
|
||||
d( 0 )
|
||||
{
|
||||
setPlainCaption(i18n("About Katana"));
|
||||
setWindowTitle(i18n("About Katana"));
|
||||
setButtons(KDialog::Close);
|
||||
|
||||
KTitleWidget *titleWidget = new KTitleWidget(this);
|
||||
|
|
|
@ -178,7 +178,7 @@ void KDialogPrivate::init(KDialog *q)
|
|||
|
||||
q->connect(&mButtonSignalMapper, SIGNAL(mapped(int)), q, SLOT(slotButtonClicked(int)));
|
||||
|
||||
q->setPlainCaption(KGlobal::caption()); // set appropriate initial window title for case it gets not set later
|
||||
q->setWindowTitle(KGlobal::caption()); // set appropriate initial window title for case it gets not set later
|
||||
}
|
||||
|
||||
void KDialogPrivate::helpLinkClicked()
|
||||
|
@ -469,7 +469,7 @@ QString KDialog::makeStandardCaption( const QString &userCaption,
|
|||
void KDialog::setCaption( const QString &_caption )
|
||||
{
|
||||
const QString caption = makeStandardCaption( _caption, this );
|
||||
setPlainCaption( caption );
|
||||
setWindowTitle( caption );
|
||||
}
|
||||
|
||||
void KDialog::setCaption( const QString &caption, bool modified )
|
||||
|
@ -481,19 +481,7 @@ void KDialog::setCaption( const QString &caption, bool modified )
|
|||
flags |= ModifiedCaption;
|
||||
}
|
||||
|
||||
setPlainCaption( makeStandardCaption(caption, this, flags) );
|
||||
}
|
||||
|
||||
|
||||
void KDialog::setPlainCaption( const QString &caption )
|
||||
{
|
||||
if (QWidget *win = window()) {
|
||||
win->setWindowTitle( caption );
|
||||
#ifdef Q_WS_X11
|
||||
NETWinInfo info( QX11Info::display(), win->winId(), QX11Info::appRootWindow(), 0 );
|
||||
info.setName( caption.toUtf8().constData() );
|
||||
#endif
|
||||
}
|
||||
setWindowTitle( makeStandardCaption(caption, this, flags) );
|
||||
}
|
||||
|
||||
void KDialog::resizeLayout( QWidget *widget, int margin, int spacing ) //static
|
||||
|
|
|
@ -570,14 +570,6 @@ class KDEUI_EXPORT KDialog : public QDialog //krazy:exclude=qclasses
|
|||
*/
|
||||
virtual void setCaption( const QString &caption, bool modified );
|
||||
|
||||
/**
|
||||
* Make a plain caption without any modifications.
|
||||
*
|
||||
* @param caption Your caption. This is the string that will be
|
||||
* displayed in the window title.
|
||||
*/
|
||||
virtual void setPlainCaption( const QString &caption );
|
||||
|
||||
/**
|
||||
* Enable or disable (gray out) a general action button.
|
||||
*
|
||||
|
|
|
@ -472,7 +472,7 @@ int KMessageBox::questionYesNoListWId(WId parent_id, const QString &text,
|
|||
dialog->setEscapeButton( KDialog::No );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -533,7 +533,7 @@ int KMessageBox::questionYesNoCancelWId(WId parent_id,
|
|||
dialog->setDefaultButton( KDialog::Yes );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -621,7 +621,7 @@ int KMessageBox::warningYesNoListWId(WId parent_id, const QString &text,
|
|||
dialog->setEscapeButton( KDialog::No );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -701,7 +701,7 @@ int KMessageBox::warningContinueCancelListWId(WId parent_id, const QString &text
|
|||
dialog->setEscapeButton( KDialog::No );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -788,7 +788,7 @@ int KMessageBox::warningYesNoCancelListWId(WId parent_id, const QString &text,
|
|||
dialog->setDefaultButton( KDialog::Yes );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -843,7 +843,7 @@ void KMessageBox::errorListWId(WId parent_id, const QString &text, const QStrin
|
|||
dialog->setEscapeButton( KDialog::Ok );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -873,7 +873,7 @@ void KMessageBox::detailedErrorWId(WId parent_id, const QString &text,
|
|||
dialog->setEscapeButton( KDialog::Ok );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -917,7 +917,7 @@ void KMessageBox::sorryWId(WId parent_id, const QString &text,
|
|||
dialog->setEscapeButton( KDialog::Ok );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -946,7 +946,7 @@ void KMessageBox::detailedSorryWId(WId parent_id, const QString &text,
|
|||
dialog->setEscapeButton( KDialog::Ok );
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
@ -990,7 +990,7 @@ void KMessageBox::informationListWId(WId parent_id,const QString &text, const QS
|
|||
dialog->setEscapeButton( KDialog::Ok);
|
||||
applyOptions( dialog, options );
|
||||
if ( options & KMessageBox::PlainCaption ) {
|
||||
dialog->setPlainCaption( caption );
|
||||
dialog->setWindowTitle( caption );
|
||||
}
|
||||
if ( parent == NULL && parent_id ) {
|
||||
KWindowSystem::setMainWindow( dialog, parent_id );
|
||||
|
|
|
@ -120,7 +120,7 @@ bool DockResizeListener::eventFilter(QObject *watched, QEvent *event)
|
|||
case QEvent::Resize:
|
||||
case QEvent::Move:
|
||||
case QEvent::Hide:
|
||||
m_win->k_ptr->setSettingsDirty(KMainWindowPrivate::CompressCalls);
|
||||
m_win->k_ptr->setSettingsDirty(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -387,7 +387,7 @@ void KMainWindowPrivate::polish(KMainWindow *q)
|
|||
QDBusConnection::ExportAdaptors);
|
||||
}
|
||||
|
||||
void KMainWindowPrivate::setSettingsDirty(CallCompression callCompression)
|
||||
void KMainWindowPrivate::setSettingsDirty(bool compressCalls)
|
||||
{
|
||||
if (!letDirtySettings) {
|
||||
return;
|
||||
|
@ -395,7 +395,7 @@ void KMainWindowPrivate::setSettingsDirty(CallCompression callCompression)
|
|||
|
||||
settingsDirty = true;
|
||||
if (autoSaveSettings) {
|
||||
if (callCompression == CompressCalls) {
|
||||
if (compressCalls) {
|
||||
if (!settingsTimer) {
|
||||
settingsTimer = new QTimer(q);
|
||||
settingsTimer->setInterval(500);
|
||||
|
@ -547,7 +547,7 @@ bool KMainWindow::restore( int number, bool show )
|
|||
|
||||
void KMainWindow::setCaption( const QString &caption )
|
||||
{
|
||||
setPlainCaption( KDialog::makeStandardCaption( caption, this ) );
|
||||
setWindowTitle( KDialog::makeStandardCaption( caption, this ) );
|
||||
}
|
||||
|
||||
void KMainWindow::setCaption( const QString &caption, bool modified )
|
||||
|
@ -559,12 +559,7 @@ void KMainWindow::setCaption( const QString &caption, bool modified )
|
|||
flags |= KDialog::ModifiedCaption;
|
||||
}
|
||||
|
||||
setPlainCaption( KDialog::makeStandardCaption(caption, this, flags) );
|
||||
}
|
||||
|
||||
void KMainWindow::setPlainCaption( const QString &caption )
|
||||
{
|
||||
setWindowTitle(caption);
|
||||
setWindowTitle( KDialog::makeStandardCaption(caption, this, flags) );
|
||||
}
|
||||
|
||||
void KMainWindow::appHelpActivated( void )
|
||||
|
|
|
@ -437,14 +437,6 @@ public Q_SLOTS:
|
|||
*/
|
||||
virtual void setCaption( const QString &caption, bool modified );
|
||||
|
||||
/**
|
||||
* Make a plain caption without any modifications.
|
||||
*
|
||||
* @param caption Your caption. This is the string that will be
|
||||
* displayed in the window title.
|
||||
*/
|
||||
virtual void setPlainCaption( const QString &caption );
|
||||
|
||||
/**
|
||||
* Open the help page for the application.
|
||||
*
|
||||
|
|
|
@ -65,11 +65,7 @@ public:
|
|||
|
||||
void init(KMainWindow *_q);
|
||||
void polish(KMainWindow *q);
|
||||
enum CallCompression {
|
||||
NoCompressCalls = 0,
|
||||
CompressCalls
|
||||
};
|
||||
void setSettingsDirty(CallCompression callCompression = NoCompressCalls);
|
||||
void setSettingsDirty(bool compressCalls = false);
|
||||
void setSizeDirty();
|
||||
};
|
||||
|
||||
|
|
|
@ -296,7 +296,6 @@ KAudioPlayer::KAudioPlayer(QObject *parent)
|
|||
|
||||
setVolume(m_settings->value("state/volume", 90).toInt());
|
||||
setMute(m_settings->value("state/mute", false).toBool());
|
||||
setFullscreen(m_settings->value("state/fullscreen", false).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ public:
|
|||
The KAudioPlayer class provides an object that can be used to playback from various media
|
||||
sources including Hard-Drives (local and remote), Internet streams, CD, DVD, Blue-Ray, SMB,
|
||||
file-descriptor, raw data, you name it. It supports per-application state too, this
|
||||
includes volume, mute and fullscreen state currently.
|
||||
includes volume and mute state currently.
|
||||
|
||||
For an extended version of this class check out KMediaPlayer and KMediaWidget.
|
||||
|
||||
|
@ -225,7 +225,11 @@ signals:
|
|||
void loaded();
|
||||
//! @brief Signals that the playing state was paused/unpaused when buffering data
|
||||
void buffering(bool buffering);
|
||||
//! @brief Signals that the playing state was paused/unpaused
|
||||
/*!
|
||||
@brief Signals that the playing state was paused/unpaused
|
||||
@note You will still have to connect to the finished signal to update play/pause buttons
|
||||
(if any) when the path is done playing
|
||||
*/
|
||||
void paused(bool paused);
|
||||
//! @brief Signals that the playing state can advance at position, maybe partitially
|
||||
void seekable(bool seekable);
|
||||
|
|
|
@ -47,32 +47,20 @@ KMediaWidget::KMediaWidget(QWidget *parent, KMediaOptions options)
|
|||
connect(d->w_play, SIGNAL(clicked()), this, SLOT(setPlay()));
|
||||
connect(d->w_position, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int)));
|
||||
connect(d->w_volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int)));
|
||||
connect(d->w_fullscreen, SIGNAL(clicked()), SLOT(setFullscreen()));
|
||||
|
||||
connect(m_player, SIGNAL(paused(bool)), this, SLOT(_updatePlay(bool)));
|
||||
connect(m_player, SIGNAL(loaded()), this, SLOT(_updateLoaded()));
|
||||
connect(m_player, SIGNAL(finished()), this, SLOT(_updateFinished()));
|
||||
connect(m_player, SIGNAL(error(QString)), this, SLOT(_updateError(QString)));
|
||||
connect(m_player, SIGNAL(seekable(bool)), this, SLOT(_updateSeekable(bool)));
|
||||
connect(m_player, SIGNAL(position(double)), this, SLOT(_updatePosition(double)));
|
||||
connect(m_player, SIGNAL(finished()), this, SLOT(_updateFinished()));
|
||||
connect(m_player, SIGNAL(error(QString)), this, SLOT(_updateError(QString)));
|
||||
|
||||
if (options & DragDrop) {
|
||||
setAcceptDrops(true);
|
||||
m_player->setAcceptDrops(true);
|
||||
}
|
||||
|
||||
bool extcontrols = (options & ExtendedControls);
|
||||
if (extcontrols) {
|
||||
_updateLoaded();
|
||||
|
||||
m_menu = new QMenu(d->w_menu);
|
||||
m_menu->addAction(KIcon("document-open-remote"), i18n("O&pen URL"), this, SLOT(_menuOpenURL()));
|
||||
m_menu->addAction(KIcon("document-open"), i18n("&Open"), this, SLOT(_menuOpen()));
|
||||
m_menu->addSeparator();
|
||||
m_menu->addAction(KIcon("application-exit"), i18n("&Quit"), this, SLOT(_menuQuit()));
|
||||
connect(d->w_menu, SIGNAL(clicked()), this, SLOT(_showMenu()));
|
||||
}
|
||||
d->w_menu->setVisible(extcontrols);
|
||||
|
||||
if (options & HiddenControls) {
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
@ -139,43 +127,14 @@ void KMediaWidget::setVolume(int value)
|
|||
m_player->setVolume(value);
|
||||
}
|
||||
|
||||
QSize KMediaWidget::sizeHint() const
|
||||
void KMediaWidget::setFullscreen(int value)
|
||||
{
|
||||
return d->w_player->sizeHint();
|
||||
}
|
||||
|
||||
void KMediaWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_options & FullscreenVideo) {
|
||||
_fullscreen();
|
||||
event->ignore();
|
||||
bool fullscreen;
|
||||
if (value == -1) {
|
||||
fullscreen = !m_player->isFullscreen();
|
||||
} else {
|
||||
fullscreen = bool(value);
|
||||
}
|
||||
}
|
||||
|
||||
void KMediaWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_options & HiddenControls) {
|
||||
_updateControls(true);
|
||||
m_timer.restart();
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void KMediaWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (m_timer.elapsed() > 3000) {
|
||||
_updateControls(false);
|
||||
}
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
void KMediaWidget::_showMenu()
|
||||
{
|
||||
m_menu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void KMediaWidget::_fullscreen()
|
||||
{
|
||||
/*
|
||||
Making a QWidget go fullscreen requires quite some magic for X11
|
||||
because showFullScreen() requires the parent of the widget to be a
|
||||
|
@ -196,7 +155,20 @@ void KMediaWidget::_fullscreen()
|
|||
m_parentsizehack = m_parent->size();
|
||||
m_parenthack = new QMainWindow(m_parent);
|
||||
}
|
||||
if (m_player->isFullscreen()) {
|
||||
|
||||
if (fullscreen) {
|
||||
if (m_parenthack && m_parentsizehack.isValid() && m_parent) {
|
||||
kDebug() << i18n("using parent hack widget");
|
||||
m_parenthack->setCentralWidget(this);
|
||||
m_parenthack->showFullScreen();
|
||||
} else if (m_parent) {
|
||||
kDebug() << i18n("using parent widget");
|
||||
m_parent->showFullScreen();
|
||||
} else {
|
||||
kWarning() << i18n("cannot set fullscreen state");
|
||||
}
|
||||
m_player->setFullscreen(true);
|
||||
} else {
|
||||
if (m_parenthack && m_parentsizehack.isValid() && m_parent) {
|
||||
kDebug() << i18n("restoring parent from hack widget");
|
||||
setParent(m_parent);
|
||||
|
@ -211,29 +183,43 @@ void KMediaWidget::_fullscreen()
|
|||
kWarning() << i18n("cannot restore to non-fullscreen state");
|
||||
}
|
||||
m_player->setFullscreen(false);
|
||||
} else {
|
||||
if (m_parenthack && m_parentsizehack.isValid() && m_parent) {
|
||||
kDebug() << i18n("using parent hack widget");
|
||||
m_parenthack->setCentralWidget(this);
|
||||
m_parenthack->showFullScreen();
|
||||
} else if (m_parent) {
|
||||
kDebug() << i18n("using parent widget");
|
||||
m_parent->showFullScreen();
|
||||
} else {
|
||||
kWarning() << i18n("cannot set fullscreen state");
|
||||
}
|
||||
m_player->setFullscreen(true);
|
||||
}
|
||||
}
|
||||
|
||||
QSize KMediaWidget::sizeHint() const
|
||||
{
|
||||
return d->w_player->sizeHint();
|
||||
}
|
||||
|
||||
void KMediaWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_options & FullscreenVideo) {
|
||||
setFullscreen();
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void KMediaWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_options & HiddenControls) {
|
||||
_updateControls(true);
|
||||
m_timer.restart();
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void KMediaWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (m_timer.elapsed() > 3000) {
|
||||
_updateControls(false);
|
||||
}
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void KMediaWidget::_updateControls(bool visible)
|
||||
{
|
||||
// avoid hiding the controls until something has been played
|
||||
if (m_player->path().isEmpty()) {
|
||||
d->w_frame->setVisible(true);
|
||||
} else {
|
||||
d->w_frame->setVisible(visible);
|
||||
}
|
||||
d->w_frame->setVisible(visible);
|
||||
emit controlsHidden(visible);
|
||||
}
|
||||
|
||||
void KMediaWidget::_updatePlay(bool paused)
|
||||
|
@ -270,7 +256,7 @@ void KMediaWidget::_updateLoaded()
|
|||
|
||||
void KMediaWidget::_updateStatus(QString error)
|
||||
{
|
||||
if (m_options & ExtendedControls) {
|
||||
if (m_options & FullscreenVideo) {
|
||||
QWidget *windowwidget = window();
|
||||
if (windowwidget) {
|
||||
windowwidget->setWindowTitle(error);
|
||||
|
@ -282,64 +268,28 @@ void KMediaWidget::_updateFinished()
|
|||
{
|
||||
m_replay = true;
|
||||
|
||||
_updatePlay(true);
|
||||
}
|
||||
|
||||
void KMediaWidget::_updateError(QString error)
|
||||
{
|
||||
if (m_options & HiddenControls) {
|
||||
// show the controls until the next open
|
||||
m_timer.invalidate();
|
||||
_updateControls(true);
|
||||
}
|
||||
_updatePlay(true);
|
||||
}
|
||||
|
||||
void KMediaWidget::_updateError(QString error)
|
||||
{
|
||||
// since there are not many ways to indicate an error when
|
||||
// there are no extended controls use the play button to do so
|
||||
if (m_options & ExtendedControls) {
|
||||
if (m_options & FullscreenVideo) {
|
||||
_updateStatus(error);
|
||||
} else {
|
||||
d->w_play->setIcon(KIcon("dialog-error"));
|
||||
d->w_play->setText(i18n("Error"));
|
||||
}
|
||||
|
||||
m_replay = true;
|
||||
|
||||
d->w_position->setEnabled(false);
|
||||
}
|
||||
|
||||
void KMediaWidget::_menuOpenURL()
|
||||
{
|
||||
QString url = QInputDialog::getText(this, i18n("Input URL"),
|
||||
i18n("Supported protocols are: %1", m_player->protocols().join(",")));
|
||||
if (!url.isEmpty()) {
|
||||
if (!m_player->isPathSupported(url)) {
|
||||
kDebug() << i18n("ignoring unsupported:\n%1", url);
|
||||
QMessageBox::warning(this, i18n("Invalid URL"),
|
||||
i18n("Invalid URL:\n%1", url));
|
||||
} else {
|
||||
open(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KMediaWidget::_menuOpen()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, i18n("Select paths"));
|
||||
if (!path.isEmpty()) {
|
||||
if (!m_player->isPathSupported(path)) {
|
||||
kDebug() << i18n("ignoring unsupported:\n%1", path);
|
||||
QMessageBox::warning(this, i18n("Invalid path"),
|
||||
i18n("The path is invalid:\n%1", path));
|
||||
} else {
|
||||
open(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KMediaWidget::_menuQuit()
|
||||
{
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
void KMediaWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls()) {
|
||||
|
|
|
@ -22,12 +22,11 @@
|
|||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
#include <QElapsedTimer>
|
||||
#include <QMenu>
|
||||
#include <kmediaplayer_export.h>
|
||||
#include <kmediaplayer.h>
|
||||
|
||||
/*!
|
||||
The KMediaPlayer class provides an embedable widget that can be used to playback from various
|
||||
The KMediaWidget class provides an embedable widget that can be used to playback from various
|
||||
media sources including Hard-Drives (local and remote), Internet streams, CD, DVD, Blue-Ray,
|
||||
SMB, file-descriptor, raw data, you name it. Unlike KMediaPlayer it provides interactive media
|
||||
controls to play/pause, seek to position and set volume. It is ment to be a simple player but
|
||||
|
@ -41,10 +40,10 @@
|
|||
player->open("http://video.webmfiles.org/big-buck-bunny_trailer.webm");
|
||||
@endcode
|
||||
|
||||
@note You should construct it with parent widget so that it can be layered on top of it.
|
||||
Otherwise when a video is played the widget will be floating. Ensuring that the widget has
|
||||
parent is a key to the fullscreen support as it will ask the parent to maximize itself when
|
||||
that needs to happen to ensure that the media controls are visible.
|
||||
@note You should construct it with parent widget, preferably a QMainWindow so that it can be
|
||||
layered on top of it. Otherwise when a video is played the widget will be floating. Ensuring
|
||||
that the widget has parent is a key to the fullscreen support as it will ask the parent to
|
||||
maximize itself when that needs to happen to ensure that the media controls are visible.
|
||||
@warning The API is not stable yet and it may break in the future!
|
||||
@see KMediaPlayer
|
||||
@todo keyboard shortcuts
|
||||
|
@ -67,17 +66,13 @@ public:
|
|||
@long Provide fullscreen option, it is option because it will ask the parent to do it
|
||||
*/
|
||||
FullscreenVideo = 2,
|
||||
/*!
|
||||
@long Currently only a menu button with some goodies
|
||||
*/
|
||||
ExtendedControls = 4,
|
||||
/*!
|
||||
@long After a certain ammount of time the controls will hide themselfs allowing more
|
||||
screen space to be taken by the display widget
|
||||
*/
|
||||
HiddenControls = 5,
|
||||
HiddenControls = 4,
|
||||
//! @brief All available options
|
||||
AllOptions = DragDrop | FullscreenVideo | ExtendedControls | HiddenControls,
|
||||
AllOptions = DragDrop | FullscreenVideo | HiddenControls,
|
||||
//! @brief Default options, currently none
|
||||
DefaultOptions = NoOptions
|
||||
};
|
||||
|
@ -119,6 +114,7 @@ public slots:
|
|||
@param value A tristate value for the play state, if "-1" the state will be automatically
|
||||
decided for you. If "0" it will set the state to play (unpaused) and if "1" it will set it
|
||||
to pause (paused). Whenever called it updates the play/pause button state.
|
||||
@see KMediaPlayer::play, KMediaPlayer::pause
|
||||
*/
|
||||
void setPlay(int value = -1);
|
||||
/*!
|
||||
|
@ -135,10 +131,24 @@ public slots:
|
|||
@see KMediaPlayer::setVolume
|
||||
*/
|
||||
void setVolume(int value);
|
||||
/*!
|
||||
@brief Set the fullscreen state
|
||||
@param value A tristate value for the fullscreen state, if "-1" the state will be
|
||||
automatically decided for you. If "0" it will set the state to fullscreen and if "1" it
|
||||
will set it non-fullscreen.
|
||||
@see KMediaPlayer::isFullscreen, KMediaPlayer::setFullscreen
|
||||
*/
|
||||
void setFullscreen(int value = -1);
|
||||
|
||||
signals:
|
||||
/*!
|
||||
@brief Signals that controls were hidden/unhidden
|
||||
@long This signal can be used to show/hide parent widget elements, such as menubar, when
|
||||
the media controls of this widget are hidden/unhidden
|
||||
*/
|
||||
void controlsHidden(bool hidden);
|
||||
|
||||
private slots:
|
||||
void _showMenu();
|
||||
void _fullscreen();
|
||||
void _updateControls(bool visible);
|
||||
void _updatePlay(bool paused);
|
||||
void _updateSeekable(bool seekable);
|
||||
|
@ -148,10 +158,6 @@ private slots:
|
|||
void _updateFinished();
|
||||
void _updateError(QString error);
|
||||
|
||||
void _menuOpenURL();
|
||||
void _menuOpen();
|
||||
void _menuQuit();
|
||||
|
||||
private:
|
||||
KMediaPlayer *m_player;
|
||||
KMediaOptions m_options;
|
||||
|
@ -161,7 +167,6 @@ private:
|
|||
QElapsedTimer m_timer;
|
||||
QString m_path;
|
||||
bool m_replay;
|
||||
QMenu *m_menu;
|
||||
Ui_KMediaWidgetPrivate *d;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,13 +38,13 @@
|
|||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="2">
|
||||
<widget class="QDial" name="w_volume">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="w_fullscreen">
|
||||
<property name="text">
|
||||
<string>Fullscreen</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="view-fullscreen"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -60,15 +60,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="w_menu">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="show-menu">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<item row="0" column="2">
|
||||
<widget class="QDial" name="w_volume">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -764,7 +764,7 @@ void KPluginSelector::Private::PluginDelegate::slotAboutClicked()
|
|||
const KAboutData *aboutData = factory->componentData().aboutData();
|
||||
if (!aboutData->programName().isEmpty()) { // Be sure the about data is not completely empty
|
||||
KAboutApplicationDialog aboutPlugin(aboutData, itemView());
|
||||
aboutPlugin.setPlainCaption(i18nc("Used only for plugins", "About %1", aboutData->programName()));
|
||||
aboutPlugin.setWindowTitle(i18nc("Used only for plugins", "About %1", aboutData->programName()));
|
||||
aboutPlugin.exec();
|
||||
return;
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ void KPluginSelector::Private::PluginDelegate::slotAboutClicked()
|
|||
}
|
||||
}
|
||||
KAboutApplicationDialog aboutPlugin(&aboutData, itemView());
|
||||
aboutPlugin.setPlainCaption(i18nc("Used only for plugins", "About %1", aboutData.programName()));
|
||||
aboutPlugin.setWindowTitle(i18nc("Used only for plugins", "About %1", aboutData.programName()));
|
||||
aboutPlugin.exec();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue