summaryrefslogtreecommitdiff
path: root/src/basegui.cpp
diff options
context:
space:
mode:
authorMateusz Łukasik <mati75@linuxmint.pl>2016-08-14 15:17:04 +0200
committerMateusz Łukasik <mati75@linuxmint.pl>2016-08-14 15:17:04 +0200
commit029acf6821f034583700c26b013ffc67ad7690f7 (patch)
treefe65dfdc621b61036af67ea03b37aba0534bb485 /src/basegui.cpp
parent7b04f55feb0d50e03d013b2be0ec555d363a40b2 (diff)
Imported Upstream version 16.8.0~ds0
Diffstat (limited to 'src/basegui.cpp')
-rw-r--r--src/basegui.cpp74
1 files changed, 54 insertions, 20 deletions
diff --git a/src/basegui.cpp b/src/basegui.cpp
index cc3a889..5de6869 100644
--- a/src/basegui.cpp
+++ b/src/basegui.cpp
@@ -149,7 +149,7 @@ using namespace Global;
BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags )
: QMainWindow( parent, flags )
-#if QT_VERSION >= 0x050000
+#ifdef DETECT_MINIMIZE_WORKAROUND
, was_minimized(false)
#endif
, popup(0)
@@ -375,6 +375,10 @@ BaseGui::~BaseGui() {
delete video_preview;
}
#endif
+
+ if (mplayerwindow) {
+ delete mplayerwindow;
+ }
}
void BaseGui::createActions() {
@@ -2414,27 +2418,33 @@ void BaseGui::createAudioEqualizer() {
void BaseGui::createPlaylist() {
#if DOCK_PLAYLIST
- playlist = new Playlist(core, this, 0);
+ playlist = new Playlist(this, 0);
#else
- //playlist = new Playlist(core, this, "playlist");
- playlist = new Playlist(core, 0);
+ playlist = new Playlist(0);
#endif
+ playlist->setConfigPath(Paths::configPath());
- /*
- connect( playlist, SIGNAL(playlistEnded()),
- this, SLOT(exitFullscreenOnStop()) );
- */
connect( playlist, SIGNAL(playlistEnded()),
this, SLOT(playlistHasFinished()) );
connect( playlist, SIGNAL(playlistEnded()),
mplayerwindow, SLOT(showLogo()) );
- /*
- connect( playlist, SIGNAL(visibilityChanged()),
- this, SLOT(playlistVisibilityChanged()) );
- */
+ connect(playlist, SIGNAL(requestToPlayFile(const QString &, int)),
+ core, SLOT(open(const QString &, int)));
+
+ connect(playlist, SIGNAL(requestToAddCurrentFile()), this, SLOT(addToPlaylistCurrentFile()));
+ if (playlist->automaticallyPlayNext()) {
+ connect( core, SIGNAL(mediaFinished()), playlist, SLOT(playNext()), Qt::QueuedConnection );
+ }
+ connect( core, SIGNAL(mplayerFailed(QProcess::ProcessError)), playlist, SLOT(playerFailed(QProcess::ProcessError)) );
+ connect( core, SIGNAL(mplayerFinishedWithError(int)), playlist, SLOT(playerFinishedWithError(int)) );
+ connect(core, SIGNAL(mediaDataReceived(const MediaData &)), playlist, SLOT(getMediaInfo(const MediaData &)));
+
+#ifdef PLAYLIST_DOWNLOAD
+ playlist->setMaxItemsUrlHistory( pref->history_urls->maxItems() );
+#endif
}
void BaseGui::createPanel() {
@@ -3190,6 +3200,9 @@ void BaseGui::applyNewPreferences() {
playlist->setPlayFilesFromStart(pl->playFilesFromStart());
playlist->setIgnorePlayerErrors(pl->ignorePlayerErrors());
+#ifdef PLAYLIST_DOWNLOAD
+ playlist->setMaxItemsUrlHistory( pref->history_urls->maxItems() );
+#endif
if (need_update_language) {
translator->load(pref->language);
@@ -5204,6 +5217,14 @@ void BaseGui::playlistHasFinished() {
}
}
+void BaseGui::addToPlaylistCurrentFile() {
+ qDebug("BaseGui::addToPlaylistCurrentFile");
+ if (!core->mdat.filename.isEmpty()) {
+ playlist->addItem(core->mdat.filename, "", 0);
+ playlist->getMediaInfo(core->mdat);
+ }
+}
+
void BaseGui::displayState(Core::State state) {
qDebug() << "BaseGui::displayState:" << core->stateToString();
@@ -5258,6 +5279,8 @@ void BaseGui::changeSizeFactor(int factor) {
// If fullscreen, don't resize!
if (pref->fullscreen) return;
+ if (isMaximized()) showNormal();
+
if (!pref->use_mplayer_window) {
pref->size_factor = factor;
resizeMainWindow(core->mset.win_width, core->mset.win_height);
@@ -5271,8 +5294,8 @@ void BaseGui::toggleDoubleSize() {
void BaseGui::resizeWindow(int w, int h) {
qDebug("BaseGui::resizeWindow: %d, %d", w, h);
- // If fullscreen, don't resize!
- if (pref->fullscreen) return;
+ // If fullscreen or maximized, don't resize!
+ if (pref->fullscreen || isMaximized()) return;
if ( (pref->resize_method==Preferences::Never) && (panel->isVisible()) ) {
return;
@@ -5320,11 +5343,12 @@ void BaseGui::resizeMainWindow(int w, int h) {
qDebug("BaseGui::resizeWindow: new_width: %d new_height: %d", new_width, new_height);
-#if 0
- QSize desktop_size = DesktopInfo::desktop_size(this);
+#ifdef Q_OS_WIN
+ QRect desktop_rect = QApplication::desktop()->availableGeometry(this);
+ QSize desktop_size = QSize(desktop_rect.width(), desktop_rect.height());
//desktop_size.setWidth(1000); desktop_size.setHeight(1000); // test
if (new_width > desktop_size.width()) {
- double aspect = (double) new_width / new_height;
+ //double aspect = (double) new_width / new_height;
qDebug("BaseGui::resizeWindow: width (%d) is larger than desktop width (%d)", new_width, desktop_size.width());
new_width = desktop_size.width();
/*
@@ -5352,7 +5376,7 @@ void BaseGui::resizeMainWindow(int w, int h) {
// Check if a part of the window is outside of the desktop
// and center the window in that case
if ((pref->center_window_if_outside) && (!core->mdat.novideo)) {
- QRect screen_rect = QApplication::desktop()->screenGeometry(this);
+ QRect screen_rect = QApplication::desktop()->availableGeometry(this);
QPoint right_bottom = QPoint(this->pos().x() + this->width(), this->pos().y() + this->height());
qDebug("BaseGui::resizeWindow: right bottom point: %d, %d", right_bottom.x(), right_bottom.y());;
if (!screen_rect.contains(right_bottom) || !screen_rect.contains(this->pos())) {
@@ -5360,6 +5384,12 @@ void BaseGui::resizeMainWindow(int w, int h) {
//move(screen_rect.x(), screen_rect.y());
int x = screen_rect.x() + ((screen_rect.width() - width()) / 2);
int y = screen_rect.y() + ((screen_rect.height() - height()) / 2);
+ //qDebug() << "BaseGui::resizeWindow: screen_rect.x:" << screen_rect.x() << "screen_rect.y:" << screen_rect.y();
+ //qDebug() << "BaseGui::resizeWindow: width:" << ((screen_rect.width() - width()) / 2);
+ //qDebug() << "BaseGui::resizeWindow: height:" << ((screen_rect.height() - height()) / 2);
+ if (x < screen_rect.x()) x = screen_rect.x();
+ if (y < screen_rect.y()) y = screen_rect.y();
+ //qDebug() << "BaseGui::resizeWindow: x:" << x << "y:" << y;
move(x, y);
}
}
@@ -5507,7 +5537,9 @@ void BaseGui::changeStayOnTop(int stay_on_top) {
void BaseGui::checkStayOnTop(Core::State state) {
qDebug("BaseGui::checkStayOnTop");
if ((!pref->fullscreen) && (pref->stay_on_top == Preferences::WhilePlayingOnTop)) {
- setStayOnTop((state == Core::Playing));
+ if (state != Core::Buffering) {
+ setStayOnTop((state == Core::Playing));
+ }
}
}
@@ -5757,8 +5789,10 @@ void BaseGui::moveWindowDiff(QPoint diff) {
if (count > 3) {
//qDebug() << "BaseGui::moveWindowDiff:" << d;
QPoint new_pos = w->pos() + d;
+ /*
if (new_pos.y() < 0) new_pos.setY(0);
if (new_pos.x() < 0) new_pos.setX(0);
+ */
//qDebug() << "BaseGui::moveWindowDiff: new_pos:" << new_pos;
w->move(new_pos);
count = 0;
@@ -5781,7 +5815,7 @@ void BaseGui::delayedSeek() {
#endif
-#if QT_VERSION < 0x050000
+#ifndef DETECT_MINIMIZE_WORKAROUND
void BaseGui::showEvent( QShowEvent * ) {
qDebug("BaseGui::showEvent");