added drop support, latest changes from gta5sync

This commit is contained in:
Syping 2017-07-28 19:53:07 +02:00
parent e041c576cd
commit 8ddd79d667
12 changed files with 288 additions and 102 deletions

View File

@ -24,15 +24,15 @@ before_script:
- echo "Grand Theft Auto V Snapmatic and Savegame viewer" > ./description-pak
script:
- qmake -qt=5 "DEFINES+=GTA5SYNC_DAILYB=\\\\\\\"$PACKAGE_VERSION-rc1\\\\\\\"" ../gta5view.pro
- qmake -qt=5 "DEFINES+=GTA5SYNC_DAILYB=\\\\\\\"$PACKAGE_VERSION-rc2\\\\\\\"" ../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --pkgname=gta5view --pkgversion=$PACKAGE_VERSION --pkgrelease=rc1 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5 --pakdir=../package
- sudo checkinstall -D --default --nodoc --pkgname=gta5view --pkgversion=$PACKAGE_VERSION --pkgrelease=rc2 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5 --pakdir=../package
deploy:
provider: releases
api_key:
secure: "o7VneEz1aHfdVwZvOZLfopf6uJWNrFsZaBvunTmXFzpmNFhlNS1qwqgMUkIA2yBRbZ3wIzVs4vfwIHv7W9yE/PqK+AYL+R8+AwKGrwlgT4HqJNuk6VM/LNJ6GwT/qkQuaoOVw29bUjmzzgIRdHmw53SlJv6Hh1VE8HphlTT//aex6nCfcFhUZ0BETdZDWz5FSHwL3NalUoqfKfQrJeky5RXzCyCANQC2tKt0bV46GaWIgWrDo2KCTNqPtRWWf5GDmnkXE5IYRMQ3mXvO9iYh0v5Y2jo4PiXGUiFUU6Z3aAWFAiPdGclrBO697cf3lCTzDMhuCETR153qFYsLShUlFf61ITAmCeHAWETjZDri0lmPONo3GoNB6alGfYEA51qw14kXakrTpICtTJj7gw/gtUYOabW6hrzmieNzMBIy62RikDPjyakFnuwW2qNHRlD65e0jYv+6nCpb6E+OV16Ysh1zhV2vTfpfzVmSuyu2J+ELqXD3OZCXRSPpDIih9UQ8335p8FBji6jHORcgym/TRgdgRmENibh8tLzWp+UjpWHuWfcpvZgOskjfwU0iDMCayMJ7tDpOhXHcAhDRnd6XRIiOJ5YZCzflj2nEwmt3YUd7DwXS/AU+WHOmcNQBjXBxF/FJa35XXcy3HKJM5TTKqtph3medo30us5yXHeG6NNg="
file: "../package/gta5view_$PACKAGE_VERSION-rc1_amd64.deb"
file: "../package/gta5view_$PACKAGE_VERSION-rc2_amd64.deb"
skip_cleanup: true
on:
tags: true

View File

@ -142,5 +142,9 @@ qreal AppEnv::screenRatio()
#else
qreal dpi = qApp->desktop()->logicalDpiX();
#endif
#ifdef Q_OS_MAC
return (dpi / 72);
#else
return (dpi / 96);
#endif
}

View File

@ -158,6 +158,10 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
installEventFilter(ui->labPicture);
ui->labPicture->setFixedSize(960 * screenRatio, 536 * screenRatio);
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
// Pre-adapt window for DPI
setFixedWidth(960 * screenRatio);
setFixedHeight(536 * screenRatio);
}
PictureDialog::~PictureDialog()

View File

@ -51,6 +51,19 @@
</property>
</widget>
</item>
<item>
<spacer name="vsJSONUpper">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="jsonFrame">
<property name="frameShape">

View File

@ -69,6 +69,7 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
QColor baseColor = palette.base().color();
ui->labVersion->setText(ui->labVersion->text().arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
ui->saProfile->setStyleSheet(QString("QWidget#saProfileContent{background-color: rgb(%1, %2, %3)}").arg(QString::number(baseColor.red()),QString::number(baseColor.green()),QString::number(baseColor.blue())));
ui->saProfileContent->setFilesMode(true);
if (QIcon::hasThemeIcon("dialog-close"))
{
@ -77,8 +78,13 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
#ifndef Q_OS_MAC
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
#else
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
#endif
}
ProfileInterface::~ProfileInterface()
@ -415,6 +421,23 @@ fileDialogPreOpen: //Work?
}
else if (selectedFiles.length() > 1)
{
importFilesProgress(selectedFiles);
}
else
{
QMessageBox::warning(this, tr("Import"), tr("No valid file is selected"));
goto fileDialogPreOpen; //Work?
}
}
settings.setValue(profileName + "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName + "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
void ProfileInterface::importFilesProgress(QStringList selectedFiles)
{
int maximumId = selectedFiles.length();
int overallId = 1;
int currentId = 0;
@ -480,18 +503,6 @@ fileDialogPreOpen: //Work?
errorStr.remove(0, 2);
QMessageBox::warning(this, tr("Import"), tr("Import failed with...\n\n%1").arg(errorStr));
}
}
else
{
QMessageBox::warning(this, tr("Import"), tr("No valid file is selected"));
goto fileDialogPreOpen; //Work?
}
}
settings.setValue(profileName + "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName + "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
bool ProfileInterface::importFile(QString selectedFile, bool notMultiple, int currentId)
@ -1097,23 +1108,17 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
contextMenu.addMenu(&editMenu);
contextMenu.addMenu(&exportMenu);
contextMenu.addAction(SnapmaticWidget::tr("&Remove"), picWidget, SLOT(on_cmdDelete_clicked()));
if (picWidget->isSelected())
{
contextMenu.addSeparator();
if (!picWidget->isSelected()) { contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, SLOT(pictureSelected())); }
if (picWidget->isSelected()) { contextMenu.addAction(SnapmaticWidget::tr("&Deselect"), picWidget, SLOT(pictureSelected())); }
if (selectedWidgets() != widgets.count())
{
contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A"));
}
if (selectedWidgets() != 0)
{
contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D"));
}
}
else
{
contextMenu.addSeparator();
contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, SLOT(pictureSelected()));
contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A"));
}
contextMenu.exec(ev->globalPos());
}
@ -1124,22 +1129,41 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
contextMenu.addAction(SavegameWidget::tr("&View"), sgdWidget, SLOT(on_cmdView_clicked()));
contextMenu.addAction(SavegameWidget::tr("&Export"), sgdWidget, SLOT(on_cmdCopy_clicked()));
contextMenu.addAction(SavegameWidget::tr("&Remove"), sgdWidget, SLOT(on_cmdDelete_clicked()));
if (sgdWidget->isSelected())
{
contextMenu.addSeparator();
if (!sgdWidget->isSelected()) { contextMenu.addAction(SavegameWidget::tr("&Select"), this, SLOT(savegameSelected())); }
if (sgdWidget->isSelected()) { contextMenu.addAction(SavegameWidget::tr("&Deselect"), this, SLOT(savegameSelected())); }
if (!sgdWidget->isSelected()) { contextMenu.addAction(SavegameWidget::tr("&Select"), sgdWidget, SLOT(savegameSelected())); }
if (sgdWidget->isSelected()) { contextMenu.addAction(SavegameWidget::tr("&Deselect"), sgdWidget, SLOT(savegameSelected())); }
if (selectedWidgets() != widgets.count())
{
contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A"));
}
if (selectedWidgets() != 0)
{
contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D"));
}
}
else
{
contextMenu.addSeparator();
contextMenu.addAction(SavegameWidget::tr("&Select"), sgdWidget, SLOT(savegameSelected()));
contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A"));
}
contextMenu.exec(ev->globalPos());
}
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
{
if (!mimeData) return;
QStringList pathList;
QList<QUrl> urlList = mimeData->urls();
foreach(const QUrl &currentUrl, urlList)
{
if (currentUrl.isLocalFile())
{
pathList.append(currentUrl.toLocalFile());
}
}
if (pathList.length() == 1)
{
QString selectedFile = pathList.at(0);
importFile(selectedFile, true, 0);
}
else if (pathList.length() > 1)
{
importFilesProgress(pathList);
}
}

View File

@ -74,6 +74,7 @@ private slots:
void profileWidgetDeselected();
void dialogNextPictureRequested(QWidget *dialog);
void dialogPreviousPictureRequested(QWidget *dialog);
void on_saProfileContent_dropped(const QMimeData *mimeData);
private:
ProfileDatabase *profileDB;
@ -94,6 +95,7 @@ private:
int contentMode;
bool importFile(QString selectedFile, bool notMultiple, int currentId);
void importFilesProgress(QStringList selectedFiles);
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);
bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true);
void pictureLoaded(SnapmaticPicture *picture, bool inserted);

View File

@ -103,15 +103,18 @@
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="saProfileContent">
<widget class="UiModWidget" name="saProfileContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>398</width>
<height>257</height>
</rect>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="vlProfile">
<property name="leftMargin">
<number>0</number>
@ -225,6 +228,17 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModWidget</class>
<extends>QWidget</extends>
<header>UiModWidget.h</header>
<container>1</container>
<slots>
<signal>dropped(QMimeData*)</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -50,7 +50,7 @@
#ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.4.0-rc1"
#define GTA5SYNC_APPVER "1.4.0-rc2"
#else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB)
#endif

View File

@ -56,7 +56,8 @@ SOURCES += main.cpp \
StandardPaths.cpp \
StringParser.cpp \
UserInterface.cpp \
uimod/UiModLabel.cpp
uimod/UiModLabel.cpp \
uimod/UiModWidget.cpp
HEADERS += \
AboutDialog.h \
@ -87,7 +88,8 @@ HEADERS += \
StandardPaths.h \
StringParser.h \
UserInterface.h \
uimod/UiModLabel.h
uimod/UiModLabel.h \
uimod/UiModWidget.h
PRECOMPILED_HEADER += config.h

View File

@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 4, 0, 5
PRODUCTVERSION 1, 4, 0, 5
FILEVERSION 1, 4, 0, 6
PRODUCTVERSION 1, 4, 0, 6
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
@ -25,12 +25,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view\0"
VALUE "FileVersion", "1.4.0-rc1\0"
VALUE "FileVersion", "1.4.0-rc2\0"
VALUE "InternalName", "gta5view\0"
VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0"
VALUE "OriginalFilename", "gta5view.exe\0"
VALUE "ProductName", "gta5view\0"
VALUE "ProductVersion", "1.4.0-rc1\0"
VALUE "ProductVersion", "1.4.0-rc2\0"
END
END
END

76
uimod/UiModWidget.cpp Normal file
View File

@ -0,0 +1,76 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2017 Syping
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "UiModWidget.h"
#include <QStyleOption>
#include <QDropEvent>
#include <QMimeData>
#include <QPainter>
#include <QDebug>
#include <QUrl>
UiModWidget::UiModWidget(QWidget *parent) : QWidget(parent)
{
filesMode = false;
}
UiModWidget::~UiModWidget()
{
}
void UiModWidget::setFilesMode(bool filesModeEnabled)
{
filesMode = filesModeEnabled;
}
void UiModWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
{
if (filesMode && dragEnterEvent->mimeData()->hasUrls())
{
QStringList pathList;
QList<QUrl> urlList = dragEnterEvent->mimeData()->urls();
foreach(const QUrl &currentUrl, urlList)
{
if (currentUrl.isLocalFile())
{
pathList.append(currentUrl.toLocalFile());
}
}
if (!pathList.isEmpty())
{
dragEnterEvent->acceptProposedAction();
}
}
}
void UiModWidget::dropEvent(QDropEvent *dropEvent)
{
dropEvent->acceptProposedAction();
emit dropped(dropEvent->mimeData());
}
void UiModWidget::paintEvent(QPaintEvent *paintEvent)
{
Q_UNUSED(paintEvent)
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

47
uimod/UiModWidget.h Normal file
View File

@ -0,0 +1,47 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2017 Syping
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef UIMODWIDGET_H
#define UIMODWIDGET_H
#include <QMimeData>
#include <QWidget>
#include <QString>
#include <QSize>
class UiModWidget : public QWidget
{
Q_OBJECT
public:
UiModWidget(QWidget *parent = 0);
void setFilesMode(bool enabled);
~UiModWidget();
protected:
void dragEnterEvent(QDragEnterEvent *dragEnterEvent);
void dropEvent(QDropEvent *dropEvent);
void paintEvent(QPaintEvent *paintEvent);
private:
bool filesMode;
signals:
void dropped(const QMimeData *mimeData);
};
#endif // UIMODWIDGET_H