Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
# binaries
/src/smplayer
/webserver/simple_web_server
webserver/simple_web_server.exe
version
src/smplayer.pro.user
15 changes: 13 additions & 2 deletions src/actionseditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <QMessageBox>
#include <QFileInfo>
#include <QRegExp>
#if QT_VERSION_MAJOR >= 6
#include <QRegularExpression>
#endif
#include <QApplication>
#include <QAction>
#include <QDebug>
Expand Down Expand Up @@ -539,7 +542,9 @@ bool ActionsEditor::saveActionsTable(const QString & filename) {
QFile f( filename );
if ( f.open( QIODevice::WriteOnly ) ) {
QTextStream stream( &f );
#if QT_VERSION_MAJOR < 6
stream.setCodec("UTF-8");
#endif

for (int row = 0; row < table->rowCount(); row++) {
stream << table->item(row, COL_NAME)->text() << "\t"
Expand Down Expand Up @@ -580,15 +585,21 @@ bool ActionsEditor::loadActionsTable(const QString & filename) {
#endif

QTextStream stream( &f );
stream.setCodec("UTF-8");
#if QT_VERSION_MAJOR < 6
stream.setCodec("UTF-8");
#endif

QString line;
while ( !stream.atEnd() ) {
line = stream.readLine().trimmed();
qDebug() << "ActionsEditor::loadActions: line:" << line;
QString name;
QString accelText;
int pos = line.indexOf(QRegExp("\\t|\\s"));
#if QT_VERSION_MAJOR < 6
int pos = line.indexOf(QRegExp("\\t|\\s"));
#else
int pos = line.indexOf(QRegularExpression("\\t|\\s"));
#endif
//qDebug() << "ActionsEditor::loadActions: pos:" << pos;
if (pos == -1) {
name = line;
Expand Down
75 changes: 62 additions & 13 deletions src/basegui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
#include <QInputDialog>
#include <QClipboard>
#include <QMimeData>
#if QT_VERSION_MAJOR < 6
#include <QDesktopWidget>
#else
#include <QOperatingSystemVersion>
#endif

#include <QtCore/qmath.h>

Expand Down Expand Up @@ -3826,7 +3830,11 @@ void BaseGui::updateRecents() {
//if (fi.exists()) filename = fi.fileName(); // Can be slow

// Let's see if it looks like a file (no dvd://1 or something)
if (fullname.indexOf(QRegExp("^.*://.*")) == -1) filename = fi.fileName();
#if QT_VERSION_MAJOR < 6
if (fullname.indexOf(QRegExp("^.*://.*")) == -1) filename = fi.fileName();
#else
if (fullname.indexOf(QRegularExpression("^.*://.*")) == -1) filename = fi.fileName();
#endif

if (filename.size() > 85) {
filename = filename.left(80) + "...";
Expand Down Expand Up @@ -4831,9 +4839,13 @@ void BaseGui::toggleFullscreen(bool b) {

aboutToEnterFullscreen();

#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
// Hack to avoid the windows taskbar to be visible on Windows XP
if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
#if QT_VERSION_MAJOR < 6
if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
#else
if (QOperatingSystemVersion::current() < QOperatingSystemVersionBase{ QOperatingSystemVersionBase::Windows, 6, 0 }) {
#endif
if (!pref->pause_when_hidden) hide();
}
#endif
Expand Down Expand Up @@ -5541,7 +5553,11 @@ void BaseGui::resizeMainWindow(int w, int h) {
int diff_height = this->height() - panel->height();

#if 1
#if QT_VERSION_MAJOR < 6
QRect desktop_rect = QApplication::desktop()->availableGeometry(this);
#else
QRect desktop_rect = QGuiApplication::primaryScreen()->availableGeometry();
#endif
QSize desktop_size = QSize(desktop_rect.width(), desktop_rect.height());

if (w + diff_width > desktop_size.width() || h + diff_height > desktop_size.height()) {
Expand Down Expand Up @@ -5609,8 +5625,12 @@ 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()->availableGeometry(this);
QPoint right_bottom = QPoint(this->pos().x() + this->width(), this->pos().y() + this->height());
#if QT_VERSION_MAJOR < 6
QRect screen_rect = QApplication::desktop()->availableGeometry(this);
#else
QRect screen_rect = QGuiApplication::primaryScreen()->availableGeometry();
#endif
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())) {
qDebug("BaseGui::resizeWindow: the window is outside of the desktop, it will be moved");
Expand Down Expand Up @@ -5655,8 +5675,12 @@ void BaseGui::hidePanel() {
void BaseGui::centerWindow() {
qDebug("BaseGui::centerWindow");
if (pref->center_window && !pref->fullscreen && isVisible()) {
QRect r = QApplication::desktop()->screenGeometry(this);
// r.setX(500); r.setY(150); // Test
#if QT_VERSION_MAJOR < 6
QRect r = QApplication::desktop()->availableGeometry(this);
#else
QRect r = QGuiApplication::primaryScreen()->availableGeometry();
#endif
// r.setX(500); r.setY(150); // Test
qDebug() << "BaseGui::centerWindow: desktop rect:" << r;
int x = r.x() + ((r.width() - width()) / 2);
int y = r.y() + ((r.height() - height()) / 2);
Expand Down Expand Up @@ -5822,8 +5846,13 @@ QString BaseGui::loadQss(QString filename) {
path = current.relativeFilePath(td);
}
#endif
#if QT_VERSION_MAJOR < 6
stylesheet.replace(QRegExp("url\\s*\\(\\s*([^\\);]+)\\s*\\)", Qt::CaseSensitive, QRegExp::RegExp2),
QString("url(%1\\1)").arg(path + "/"));
#else
stylesheet.replace(QRegularExpression("url\\s*\\(\\s*([^\\);]+)\\s*\\)", QRegularExpression::CaseInsensitiveOption),
QString("url(%1\\1)").arg(path + "/"));
#endif
//qDebug("BaseGui::loadQss: styleSheet: %s", stylesheet.toUtf8().constData());
return stylesheet;
}
Expand Down Expand Up @@ -6408,18 +6437,30 @@ bool BaseGui::winEvent ( MSG * m, long * result ) {
QString text = QString::fromWCharArray((TCHAR*)m->lParam);
qDebug() << "BaseGui::winEvent: WM_SETTINGCHANGE:" << text;

#if ((QT_VERSION >= 0x040807 && QT_VERSION < 0x050000) || (QT_VERSION >= 0x050500))
#if ((QT_VERSION >= 0x040807 && QT_VERSION < 0x050000) || (QT_VERSION >= 0x050500))
#if QT_VERSION_MAJOR < 6
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10) {
#else
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) {
#endif
// Windows 10 check
if (text == "UserInteractionMode") {
QTimer::singleShot(1000, this, SLOT(checkSystemTabletMode()));
}
}
else
if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8_1) {
if (text == "ConvertibleSlateMode") checkSystemTabletMode();
#if QT_VERSION_MAJOR < 6
if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8_1) {
#else
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8_1 && QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows8_1) {
#endif
if (text == "ConvertibleSlateMode") checkSystemTabletMode();
}
#endif
#else
if (text == "UserInteractionMode") {
QTimer::singleShot(1000, this, SLOT(checkSystemTabletMode()));
}
#endif

*result = 0;
return true;
Expand Down Expand Up @@ -6468,7 +6509,11 @@ bool BaseGui::nativeEvent(const QByteArray &eventType, void * message, long * re

void BaseGui::checkSystemTabletMode() {
#if ((QT_VERSION >= 0x040807 && QT_VERSION < 0x050000) || (QT_VERSION >= 0x050500))
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10) {
#if QT_VERSION_MAJOR < 6
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10) {
#else
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) {
#endif
// Windows 10 code (don't know if this works on Windows 8)
QSettings set("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ImmersiveShell", QSettings::NativeFormat);
QVariant v = set.value("TabletMode");
Expand All @@ -6479,8 +6524,12 @@ void BaseGui::checkSystemTabletMode() {
}
}
else
if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8_1 ||
#if QT_VERSION_MAJOR < 6
if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8_1 ||
QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8)
#else
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 && QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows8_1)
#endif
{
bool slate_mode = (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0);
qDebug() << "BaseGui::checkSystemTabletMode: slate_mode:" << slate_mode;
Expand Down
10 changes: 10 additions & 0 deletions src/baseguiplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
#include <QMenu>
#include <QCloseEvent>
#include <QApplication>
#if QT_VERSION_MAJOR < 6
#include <QDesktopWidget>
#endif
#include <QTime>

#ifdef PLAYLIST_DOCKABLE
Expand Down Expand Up @@ -624,8 +626,16 @@ void BaseGuiPlus::aboutToEnterFullscreen() {
if (!playlist->isWindow() && playlistdock) {
playlistdock->setAllowedAreas(Qt::NoDockWidgetArea);

#if QT_VERSION_MAJOR < 6
int playlist_screen = QApplication::desktop()->screenNumber(playlistdock);
int mainwindow_screen = QApplication::desktop()->screenNumber(this);
#else
const QList<QScreen *> screens = QGuiApplication::screens();
QScreen *primaryScreen = QGuiApplication::primaryScreen();
QScreen *pldockScreen = playlistdock->windowHandle()->screen();
int playlist_screen = screens.indexOf(pldockScreen);
int mainwindow_screen = screens.indexOf(primaryScreen);
#endif
qDebug("BaseGuiPlus::aboutToEnterFullscreen: mainwindow screen: %d, playlist screen: %d", mainwindow_screen, playlist_screen);

fullscreen_playlist_was_visible = playlistdock->isVisible();
Expand Down
3 changes: 3 additions & 0 deletions src/colorutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

#include "colorutils.h"
#include <QWidget>
#if QT_VERSION_MAJOR >= 6
#include <QRegExp>
#endif
#include <QDebug>
#include "qtcompat.h"

Expand Down
3 changes: 3 additions & 0 deletions src/defaultgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
#include <QMenuBar>
#include <QMovie>
#include <QtCore/qmath.h>
#if QT_VERSION_MAJOR >= 6
#include <QActionGroup>
#endif

#define TOOLBAR_VERSION "2"
#define CONTROLWIDGET_VERSION "1"
Expand Down
3 changes: 3 additions & 0 deletions src/deviceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <QProcess>
#include <QFile>
#include <QSettings>
#if QT_VERSION_MAJOR >= 6
#include <QRegExp>
#endif
#include <QDebug>

#ifdef Q_OS_WIN
Expand Down
13 changes: 12 additions & 1 deletion src/favorites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <QTextStream>
#include <QInputDialog>
#include <QFileInfo>
#if QT_VERSION_MAJOR >= 6
#include <QRegExp>
#endif

//#define FIRST_MENU_ENTRY 4
#define FIRST_MENU_ENTRY 3
Expand Down Expand Up @@ -270,7 +273,11 @@ void Favorites::save() {
QFile f( _filename );
if ( f.open( QIODevice::WriteOnly ) ) {
QTextStream stream( &f );
#if QT_VERSION_MAJOR < 6
stream.setCodec("UTF-8");
#else
stream.setEncoding(QStringConverter::Utf8);
#endif

stream << "#EXTM3U" << "\n";
for (int n = 0; n < f_list.count(); n++) {
Expand Down Expand Up @@ -299,7 +306,11 @@ void Favorites::load() {
Favorite fav;

QTextStream stream( &f );
stream.setCodec("UTF-8");
#if QT_VERSION_MAJOR < 6
stream.setCodec("UTF-8");
#else
stream.setEncoding(QStringConverter::Utf8);
#endif

QString line;
while ( !stream.atEnd() ) {
Expand Down
4 changes: 4 additions & 0 deletions src/findsubtitles/findsubtitleswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ void FindSubtitlesWindow::currentItemChanged(const QModelIndex & current, const
}

void FindSubtitlesWindow::applyFilter(const QString & filter) {
#if QT_VERSION_MAJOR < 6
proxy_model->setFilterRegExp(filter);
#else
proxy_model->setFilterRegularExpression(filter);
#endif
}

void FindSubtitlesWindow::applyCurrentFilter() {
Expand Down
7 changes: 6 additions & 1 deletion src/globalshortcuts/globalshortcuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ class GlobalShortcuts : public QObject, public QAbstractNativeEventFilter
void setGrabbedKeys(MediaKeys keys);
MediaKeys grabbedKeys() { return grabbed_keys; };

virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result);
#if QT_VERSION_MAJOR < 6
virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result);
#else
virtual bool nativeEventFilter(const QByteArray & eventType, void * message, qintptr * result);
#endif


public slots:
void setEnabled(bool);
Expand Down
10 changes: 9 additions & 1 deletion src/globalshortcuts/globalshortcuts_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@
*/

#include <windows.h>
#include <QDebug>
#if QT_VERSION_MAJOR >= 6
#include "globalshortcuts.h"
#endif

#if QT_VERSION_MAJOR < 6
bool GlobalShortcuts::nativeEventFilter(const QByteArray & /*eventType*/, void * message, long * /*result*/) {
//qDebug() << "GlobalShortcuts::nativeEventFilter";
#else
bool GlobalShortcuts::nativeEventFilter(const QByteArray & /*eventType*/, void * message, qintptr * /*result*/) {
#endif
//qDebug() << "GlobalShortcuts::nativeEventFilter";

if (!isEnabled()) return false;

Expand Down
16 changes: 14 additions & 2 deletions src/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <QDir>
#include <QTextCodec>
#include <QWidget>
#if QT_VERSION_MAJOR >= 6
#include <QRegExp>
#include <QRegularExpression>
#endif
#include <QDebug>
#include "config.h"
#include "extensions.h"
Expand Down Expand Up @@ -253,7 +257,11 @@ QStringList Helper::searchForConsecutiveFiles(const QString & initial_file) {
digits = rx.cap(1).length();
current_number = rx.cap(1).toInt() + 1;
next_name = basename.left(pos) + QString("%1").arg(current_number, digits, 10, QLatin1Char('0'));
next_name.replace(QRegExp("([\\[\\]?*])"), "[\\1]");
#if QT_VERSION_MAJOR < 6
next_name.replace(QRegExp("([\\[\\]?*])"), "[\\1]");
#else
next_name.replace(QRegularExpression("([\\[\\]?*])"), "[\\1]");
#endif
next_name += "*." + extension;
qDebug("Helper::searchForConsecutiveFiles: next name = %s",next_name.toUtf8().constData());
matching_files = dir.entryList((QStringList)next_name);
Expand All @@ -277,7 +285,11 @@ QStringList Helper::searchForConsecutiveFiles(const QString & initial_file) {
files_to_add << filename;
current_number++;
next_name = basename.left(pos) + QString("%1").arg(current_number, digits, 10, QLatin1Char('0'));
next_name.replace(QRegExp("([\\[\\]?*])"), "[\\1]");
#if QT_VERSION_MAJOR < 6
next_name.replace(QRegExp("([\\[\\]?*])"), "[\\1]");
#else
next_name.replace(QRegularExpression("([\\[\\]?*])"), "[\\1]");
#endif
next_name += "*." + extension;
matching_files = dir.entryList((QStringList)next_name);
qDebug("Helper::searchForConsecutiveFiles: looking for '%s'", next_name.toUtf8().constData());
Expand Down
2 changes: 1 addition & 1 deletion src/myapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ MyApplication::MyApplication (const QString & /*appId*/, int & argc, char ** arg
: QApplication(argc, argv)
#endif
{
#if QT_VERSION >= 0x050600
#if QT_VERSION >= 0x050600 && QT_VERSION_MAJOR < 6
setFallbackSessionManagementEnabled(false);
#endif
#if QT_VERSION >= 0x050000
Expand Down
Loading