diff options
author | Mateusz Łukasik <mati75@linuxmint.pl> | 2017-02-03 08:16:09 +0100 |
---|---|---|
committer | Mateusz Łukasik <mati75@linuxmint.pl> | 2017-02-03 08:16:09 +0100 |
commit | bcae744b1bae2f5015cb3efdd0d2226150cd79e5 (patch) | |
tree | 872701745b36fbfbeb16dd1d59d485bc1e494dbd /src/basegui.cpp | |
parent | 634cd2063f449c5d38046de88a395af77e2c9ea5 (diff) |
New upstream version 17.2.0~ds0
Diffstat (limited to 'src/basegui.cpp')
-rw-r--r-- | src/basegui.cpp | 97 |
1 files changed, 80 insertions, 17 deletions
diff --git a/src/basegui.cpp b/src/basegui.cpp index 8625104..094646d 100644 --- a/src/basegui.cpp +++ b/src/basegui.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net> 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 @@ -41,7 +41,7 @@ #include <QMimeData> #include <QDesktopWidget> -#include <cmath> +#include <QtCore/qmath.h> #include "mplayerwindow.h" #include "desktopinfo.h" @@ -260,7 +260,7 @@ BaseGui::BaseGui( QWidget* parent, Qt::WindowFlags flags ) QTimer::singleShot(2000, this, SLOT(checkIfUpgraded())); #endif -#if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET) +#ifdef DONATE_REMINDER QTimer::singleShot(1000, this, SLOT(checkReminder())); #endif @@ -906,11 +906,9 @@ void BaseGui::createActions() { connect( showConfigAct, SIGNAL(triggered()), this, SLOT(helpShowConfig()) ); -#ifdef SHARE_ACTIONS donateAct = new MyAction( this, "donate" ); connect( donateAct, SIGNAL(triggered()), this, SLOT(helpDonate()) ); -#endif aboutThisAct = new MyAction( this, "about_smplayer" ); connect( aboutThisAct, SIGNAL(triggered()), @@ -1847,6 +1845,8 @@ void BaseGui::retranslateStrings() { showConfigAct->change( Images::icon("show_config"), tr("&Open configuration folder") ); #ifdef SHARE_ACTIONS donateAct->change( Images::icon("donate"), tr("&Donate / Share with your friends") ); +#else + donateAct->change( Images::icon("donate"), tr("&Donate") ); #endif aboutThisAct->change( Images::icon("logo"), tr("About &SMPlayer") ); @@ -2324,9 +2324,9 @@ void BaseGui::createMplayerWindow() { #ifdef SHARE_WIDGET sharewidget = new ShareWidget(Global::settings, mplayerwindow); mplayerwindow->setCornerWidget(sharewidget); - #ifdef SHARE_ACTIONS + //#ifdef SHARE_ACTIONS connect(sharewidget, SIGNAL(supportClicked()), this, SLOT(helpDonate())); - #endif + //#endif #endif QVBoxLayout * layout = new QVBoxLayout; @@ -2438,6 +2438,9 @@ void BaseGui::createPlaylist() { connect(playlist, SIGNAL(requestToPlayFile(const QString &, int)), core, SLOT(open(const QString &, int))); + connect(playlist, SIGNAL(requestToPlayStream(const QString &, QStringList)), + core, SLOT(openStream(const QString &, QStringList))); + connect(playlist, SIGNAL(requestToAddCurrentFile()), this, SLOT(addToPlaylistCurrentFile())); connect( core, SIGNAL(mediaFinished()), playlist, SLOT(playNextAuto()), Qt::QueuedConnection ); @@ -2990,10 +2993,8 @@ void BaseGui::populateMainMenu() { helpMenu->addAction(showConfigAct); helpMenu->addSeparator(); } - #ifdef SHARE_ACTIONS helpMenu->addAction(donateAct); helpMenu->addSeparator(); - #endif helpMenu->addAction(aboutThisAct); // Access menu @@ -3118,6 +3119,10 @@ void BaseGui::showPreferencesDialog() { pl->setAutoSort(playlist->autoSort()); pl->setFilterCaseSensitive(playlist->filterCaseSensitive()); +#ifdef PLAYLIST_DELETE_FROM_DISK + pl->allowDeleteFromDisk(playlist->isDeleteFromDiskAllowed()); +#endif + pref_dialog->show(); } @@ -3207,6 +3212,10 @@ void BaseGui::applyNewPreferences() { playlist->setAutoSort(pl->autoSort()); playlist->setFilterCaseSensitive(pl->filterCaseSensitive()); +#ifdef PLAYLIST_DELETE_FROM_DISK + playlist->allowDeleteFromDisk(pl->isDeleteFromDiskAllowed()); +#endif + #ifdef PLAYLIST_DOWNLOAD playlist->setMaxItemsUrlHistory( pref->history_urls->maxItems() ); #endif @@ -4170,7 +4179,7 @@ void BaseGui::openURL(QString url) { void BaseGui::openFile() { - qDebug("BaseGui::fileOpen"); + qDebug("BaseGui::openFile"); exitFullscreenIfNeeded(); @@ -4189,10 +4198,18 @@ void BaseGui::openFile() { } void BaseGui::openFile(QString file) { - qDebug("BaseGui::openFile: '%s'", file.toUtf8().data()); + qDebug() << "BaseGui::openFile:" << file; if ( !file.isEmpty() ) { + #ifdef Q_OS_WIN + // Check for Windows shortcuts + QFileInfo fi(file); + if (fi.isSymLink()) { + file = fi.symLinkTarget(); + } + #endif + //playlist->clear(); //playlistdock->hide(); @@ -4479,6 +4496,47 @@ void BaseGui::helpDonate() { #endif } } +#else +void BaseGui::helpDonate() { + qDebug("BaseGui::helpDonate"); + + int action = 0; + bool accepted; + showHelpDonateDialog(&accepted); + if (accepted) action = 1; + + if (action > 0) { + QSettings * set = Global::settings; + set->beginGroup("reminder"); + set->setValue("action", action); + set->endGroup(); + } +} + +void BaseGui::showHelpDonateDialog(bool * accepted) { + bool result = false; + + QMessageBox d(this); + d.setIconPixmap(Images::icon("donate")); + d.setWindowTitle(tr("Support SMPlayer")); + + QPushButton * ok_button = d.addButton(tr("Donate"), QMessageBox::YesRole); + d.addButton(tr("No"), QMessageBox::NoRole); + d.setDefaultButton(ok_button); + + d.setText("<h1>" + tr("SMPlayer needs you") + "</h1><p>" + + tr("SMPlayer is free software. However the development requires a lot of time and a lot of work.") + "<p>" + + tr("In order to keep developing SMPlayer with new features we need your help.") + "<p>" + + tr("Please consider to support the SMPlayer project by sending a donation.") + " " + + tr("Even the smallest amount will help a lot.") + ); + d.exec(); + if (d.clickedButton() == ok_button) { + QDesktopServices::openUrl(QUrl(URL_DONATE)); + result = true; + } + if (accepted != 0) *accepted = result; +} #endif void BaseGui::helpAbout() { @@ -4905,7 +4963,7 @@ void BaseGui::checkIfUpgraded() { } #endif -#if defined(SHARE_ACTIONS) && !defined(SHARE_WIDGET) +#ifdef DONATE_REMINDER void BaseGui::checkReminder() { qDebug("BaseGui::checkReminder"); @@ -4927,6 +4985,7 @@ void BaseGui::checkReminder() { if ((count != 25) && (count != 45)) return; #endif +#ifdef SHARE_ACTIONS ShareDialog d(this); //d.showRemindCheck(false); d.exec(); @@ -4938,6 +4997,12 @@ void BaseGui::checkReminder() { set->setValue("dont_show_anymore", true); set->endGroup(); } +#else + action = 0; + bool accepted; + showHelpDonateDialog(&accepted); + if (accepted) action = 1; +#endif if (action > 0) { set->beginGroup("reminder"); @@ -5276,18 +5341,16 @@ void BaseGui::displayMessage(QString message) { } void BaseGui::gotCurrentTime(double sec) { - //qDebug( "DefaultGui::displayTime: %f", sec); + //qDebug() << "BaseGui::gotCurrentTime:" << sec; static int last_second = 0; - if (floor(sec)==last_second) return; // Update only once per second - last_second = (int) floor(sec); + if (qFloor(sec) == last_second) return; // Update only once per second + last_second = qFloor(sec); QString time = Helper::formatTime( (int) sec ) + " / " + Helper::formatTime( (int) core->mdat.duration ); - //qDebug( " duration: %f, current_sec: %f", core->mdat.duration, core->mset.current_sec); - emit timeChanged(sec); emit timeChanged(time); } |