Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Commit 110bfd1

Browse files
committed
Merge branch 'dev'
2 parents 54bf2aa + ce1d1db commit 110bfd1

File tree

8 files changed

+777
-544
lines changed

8 files changed

+777
-544
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# SteaScree Changelog
22

3+
## 1.5.4
4+
* Qt 5.9.1.
5+
* Added "JPEG Quality" spinbox for situations, when SteaScree converts image to JPEG. It happens if the input image is too large for Steam Cloud or if it has non-JPEG format. Defaults to 95.
6+
* Slight redesign. Status field is now visible all the time.
7+
8+
## 1.5.3
9+
* Now the app switches to debugging to file automatically, when the it is not ran in Qt Creator.
10+
11+
## 1.5.2
12+
* Added a logic to save debug info to the debug.log file.
13+
* Fixed the bug when the app was crashing, if the Steam user personal name (nickname) was not found in config files. Closes issue #16.
14+
* Removed some unused methods.
15+
316
## 1.4.1
417
* Minor UI improvement.
518

@@ -53,4 +66,4 @@
5366

5467
## 1.0.0
5568

56-
* Initial public release.
69+
* Initial public release.

SteaScree.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ FORMS += mainwindow.ui \
2424
RESOURCES += \
2525
images.qrc
2626

27-
VERSION = 1.4.1
27+
VERSION = 1.5.4
2828

2929
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
3030

controller.cpp

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131

3232
#include <QDebug>
3333

34+
#include <QApplication>
35+
#include <QtGlobal>
36+
#include <QtDebug>
37+
#include <QTextStream>
38+
#include <QTextCodec>
39+
#include <QLocale>
40+
#include <QTime>
41+
3442

3543
Controller::Controller(QObject *parent) : QObject(parent)
3644
{
@@ -84,13 +92,17 @@ void Controller::readSettings()
8492

8593
settings->beginGroup("LastSelection");
8694
steamDir = settings->value("SteamDir", defaultSteamDir).toString();
87-
if ( QDir(steamDir).exists() )
95+
if (QDir(steamDir).exists())
8896
emit sendLabelsText(QStringList() << "label_steamDirValue", convertSlashes(steamDir));
8997
else
9098
emit sendLabelsText(QStringList() << "label_steamDirValue", "Not found, please locate manually");
9199
lastSelectedScreenshotDir = settings->value("Screenshots", QDir::currentPath()).toString();
92100
lastSelectedUserID = settings->value("UserID").toString();
93101
lastSelectedGameID = settings->value("GameID").toString();
102+
quint32 jpegQuality = settings->value("JPEGQuality").toInt();
103+
if (jpegQuality < 1 || jpegQuality > 100)
104+
jpegQuality = defaultJpegQuality;
105+
emit sendJpegQualityValue(jpegQuality);
94106
settings->endGroup();
95107

96108
settings->beginGroup("Screenshots");
@@ -103,7 +115,7 @@ void Controller::readSettings()
103115
}
104116

105117

106-
void Controller::writeSettings(QSize size, QPoint pos, QString userID, QString gameID)
118+
void Controller::writeSettings(QSize size, QPoint pos, QString userID, QString gameID, quint32 jpegQuality)
107119
{
108120
settings->beginGroup("WindowGeometry");
109121
settings->setValue("Size", size);
@@ -117,6 +129,7 @@ void Controller::writeSettings(QSize size, QPoint pos, QString userID, QString g
117129
settings->setValue("UserID", userID);
118130
if ( !gameID.isEmpty() )
119131
settings->setValue("GameID", gameID);
132+
settings->setValue("JPEGQuality", jpegQuality);
120133
settings->endGroup();
121134

122135
settings->beginGroup("Screenshots");
@@ -136,7 +149,7 @@ void Controller::checkForUpdates()
136149

137150
void Controller::handleUpdate(QNetworkReply *reply)
138151
{
139-
if ( reply->error() == QNetworkReply::NoError ) {
152+
if (reply->error() == QNetworkReply::NoError) {
140153

141154
QByteArray raw = reply->readAll();
142155
QJsonDocument doc(QJsonDocument::fromJson(raw));
@@ -167,6 +180,7 @@ void Controller::writeSettingNeverOfferUpdate()
167180
void Controller::setUserDataPaths(QString dir) // function to validate and set data paths and IDs
168181
{
169182
userDataDir = dir + "/userdata";
183+
170184
QStringList userIDsCombined;
171185

172186
vdfPaths.clear(); // there may be multiple Steam installations in the system and thus multiple VDFs
@@ -191,19 +205,24 @@ void Controller::setUserDataPaths(QString dir) // function to validate and set
191205

192206
emit sendWidgetsDisabled(widgetList << "groupBox_screenshotQueue" << "treeWidget_screenshotList", false);
193207
emit sendLabelsText(QStringList() << "label_steamDirValue", convertSlashes(dir));
194-
emit sendLabelsVisible(QStringList() << "label_status", false);
195208

196209
steamDir = dir;
197210

198211
QStringList userIDsCombinedWithNames;
199212
QListIterator<QString> i(vdfPaths);
200213
while ( i.hasNext() ) {
201214
QString current = i.next();
215+
202216
QStringList splitted = current.split('/');
217+
203218
userID = splitted.takeAt(splitted.length() - 3);
219+
204220
someID = splitted.takeAt(splitted.length() - 2);
221+
205222
userIDsCombined << userID + "/" + someID;
223+
206224
QString personalName = getPersonalNameByUserID(userID);
225+
207226
userIDsCombinedWithNames << userID + "/" + someID + personalName;
208227
}
209228

@@ -220,6 +239,7 @@ void Controller::setUserDataPaths(QString dir) // function to validate and set
220239
items = userIDsCombinedWithNames.replaceInStrings("/", "\\");
221240
userID = userID.replace("/", "\\");
222241
}
242+
223243
selectedUserID = userID;
224244

225245
emit sendToComboBox("comboBox_userID", items);
@@ -228,18 +248,23 @@ void Controller::setUserDataPaths(QString dir) // function to validate and set
228248

229249
emit sendToComboBox("comboBox_gameID", QStringList() << "loading...");
230250

251+
emit sendStatusLabelText("ready", "");
252+
emit sendLabelsVisible(QStringList() << "label_status", true);
253+
231254
QNetworkAccessManager *nam = new QNetworkAccessManager(this);
232255

233256
QObject::connect(nam, &QNetworkAccessManager::finished,
234257
this, &Controller::getGameNames);
235258

236259
nam->get(QNetworkRequest(QUrl("http://api.steampowered.com/ISteamApps/GetAppList/v2")));
237260

238-
} else
261+
} else {
239262
emit sendLabelsOnMissingStuff(false, vdfFilename);
263+
}
240264

241-
} else
265+
} else {
242266
emit sendLabelsOnMissingStuff(true, vdfFilename);
267+
}
243268
}
244269

245270

@@ -250,6 +275,7 @@ QString Controller::getPersonalNameByUserID(QString userID)
250275
{
251276
QDirIterator i(userDataDir + "/" + userID, QStringList() << "config.cfg", QDir::Files, QDirIterator::Subdirectories);
252277
while ( i.hasNext() ) {
278+
253279
configFiles << i.next();
254280
}
255281
}
@@ -265,17 +291,21 @@ QString Controller::getPersonalNameByUserID(QString userID)
265291

266292
while ( !text.atEnd() ) {
267293
QString line = text.readLine();
294+
268295
lines << line;
269296
}
270297

271298
vdf.close();
272299

273300
QRegularExpression re("^name \"(?<name>.+)\"$");
274301
int pos = lines.indexOf(re);
302+
275303
QRegularExpressionMatch matchNew;
276304

277-
if ( (lines[pos].contains(re, &matchNew)) )
305+
if ( pos != -1 && (lines[pos].contains(re, &matchNew)) ) {
306+
278307
return " <" + matchNew.captured("name") + ">";
308+
}
279309
}
280310

281311
return "";
@@ -451,12 +481,13 @@ void Controller::writeVDF() // write to VDF from list of strings. previo
451481
}
452482

453483

454-
void Controller::prepareScreenshots(QString userID, QString gameID, MainWindow *mainWindow) // this routine copies screenshots to the respective folders
484+
void Controller::prepareScreenshots(QString userID, QString gameID, quint32 jpegQuality, MainWindow *mainWindow) // this routine copies screenshots to the respective folders
455485
{ // ...and manipulates a string list copy of the VDF (file is not written yet)
456486
someScreenshotsWereNotPrepared = false;
457487
QRegularExpression desc(" <.+>$");
458488
selectedUserID = userID.replace("\\", "/").remove(desc);
459489
selectedGameID = gameID.remove(desc); // it's possible to enter game ID by hand or left what was auto-generated (with <...>)
490+
selectedJpegQuality = jpegQuality;
460491

461492
if ( lines.isEmpty() )
462493
lines = readVDF();
@@ -630,7 +661,7 @@ void Controller::prepareScreenshots(QString userID, QString gameID, MainWindow *
630661
else {
631662
sendLabelsVisible(QStringList() << "label_progress" << "progressBar_status", false);
632663
sendLabelsVisible(QStringList() << "label_status", true);
633-
emit sendStatusLabelText("none of screenshots were copied", "#ab4e52");
664+
emit sendStatusLabelText("none of screenshots were copied", warningColor);
634665
screenshotPathsPool.clear();
635666
}
636667
}
@@ -734,7 +765,7 @@ void Controller::resizeAndSaveLargeScreenshot(Screenshot screenshot)
734765
saveThumbnail(filename, image, newWidth, newHeight);
735766

736767
resizedImage = image.scaled(QSize(newWidth, newHeight), Qt::KeepAspectRatio, Qt::SmoothTransformation);
737-
resizedImage.save(copyDest + filename, "jpg", 95);
768+
resizedImage.save(copyDest + filename, "jpg", selectedJpegQuality);
738769
}
739770

740771

@@ -812,7 +843,7 @@ void Controller::pushScreenshots(QList<Screenshot> screenshotList)
812843
if ( ((extension == "jpg") || (extension == "jpeg")) && (getEncodingProcessOfJpeg(&file) == "progressive") )
813844
file.copy(copyDest + filename); // copy untouched JPEG file if it is really JPEG, is not large (or if user decided to try it upload anyway)
814845
else // ...only progressive JPEGs are copied as is, baseline or some unidentified jpegs are
815-
image.save(copyDest + filename, "jpg", 95); // ...getting processed and saved by Qt to prevent Steam Cloud to reject them
846+
image.save(copyDest + filename, "jpg", selectedJpegQuality); // ...getting processed and saved by Qt to prevent Steam Cloud to reject them
816847

817848
saveThumbnail(filename, image, width, height); // ...see issue https://github.com/Foyl/SteaScree/issues/9
818849

@@ -871,9 +902,9 @@ void Controller::pushScreenshots(QList<Screenshot> screenshotList)
871902
emit sendDirStatusLabelsVisible(true);
872903

873904
if (someScreenshotsWereNotPrepared)
874-
emit sendStatusLabelText("some screenshots were not copied", "#ab4e52");
905+
emit sendStatusLabelText("some screenshots were not copied", warningColor);
875906
else
876-
emit sendStatusLabelText("screenshots are ready for preparation", "grey");
907+
emit sendStatusLabelText("screenshots are ready for preparation", "");
877908

878909
emit sendWidgetsDisabled(QStringList() << "pushButton_prepare", false);
879910
}
@@ -941,12 +972,6 @@ void Controller::returnLastSelectedScreenshotDir()
941972
}
942973

943974

944-
void Controller::returnScreenshotPathPoolLength()
945-
{
946-
emit sendProgressBarLength(screenshotPathsPool.length());
947-
}
948-
949-
950975
void Controller::returnSteamDir()
951976
{
952977
emit sendSteamDir(steamDir);

controller.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Controller : public QObject
4444
QString lastSelectedScreenshotDir;
4545
QString lastSelectedUserID;
4646
QString lastSelectedGameID;
47+
quint32 selectedJpegQuality;
4748
QStringList copiedGames;
4849
QString copyDest;
4950
qint32 opening;
@@ -60,6 +61,16 @@ class Controller : public QObject
6061
QTreeWidgetDragAndDrop *treeWidget;
6162
const QStringList imageFormatsSupported = QStringList() << "jpg" << "jpeg" << "png" << "bmp" << "tif" << "tiff";
6263
bool someScreenshotsWereNotPrepared;
64+
void pushScreenshots(QList<Screenshot> screenshotList);
65+
void resizeAndSaveLargeScreenshot(Screenshot screenshot);
66+
void getUserDecisionAboutLargeScreenshots(QList<Screenshot> screenshotList, MainWindow *mainWindow);
67+
void saveThumbnail(QString filename, QImage image, quint32 width, quint32 height);
68+
void checkForUpdates();
69+
QString getPersonalNameByUserID(QString userID);
70+
void getShortcutNames();
71+
QString getEncodingProcessOfJpeg(QFile *file);
72+
const QString warningColor = "#ab4e52";
73+
const quint32 defaultJpegQuality = 95;
6374

6475

6576
#if defined(Q_OS_WIN32)
@@ -70,15 +81,6 @@ class Controller : public QObject
7081
const QString os = "macOS";
7182
#endif
7283

73-
void pushScreenshots(QList<Screenshot> screenshotList);
74-
void resizeAndSaveLargeScreenshot(Screenshot screenshot);
75-
void getUserDecisionAboutLargeScreenshots(QList<Screenshot> screenshotList, MainWindow *mainWindow);
76-
void saveThumbnail(QString filename, QImage image, quint32 width, quint32 height);
77-
void checkForUpdates();
78-
QString getPersonalNameByUserID(QString userID);
79-
void getShortcutNames();
80-
QString getEncodingProcessOfJpeg(QFile *file);
81-
8284

8385
signals:
8486
void adjustButtons(QList<QPushButton*> buttonList, QString os);
@@ -105,17 +107,17 @@ class Controller : public QObject
105107
void setupStatusArea(quint32 progressBarMaximum);
106108
void sendDirStatusLabelsVisible(bool visible);
107109
void sendUpdateInfo(QString version, QString link);
110+
void sendJpegQualityValue(quint32 jpegQualityValue);
108111

109112

110113
public slots:
111114
void getButtonList(QList<QPushButton *> buttonList);
112-
void writeSettings(QSize size, QPoint pos, QString userID, QString gameID);
115+
void writeSettings(QSize size, QPoint pos, QString userID, QString gameID, quint32 jpegQuality);
113116
void removeEntryFromScreenshotPathsPool(QString entry);
114117
void returnLastSelectedScreenshotDir();
115118
void clearScreenshotPathsPool();
116119
void clearState();
117-
void returnScreenshotPathPoolLength();
118-
void prepareScreenshots(QString userID, QString gameID, MainWindow *mainWindow);
120+
void prepareScreenshots(QString userID, QString gameID, quint32 jpegQuality, MainWindow *mainWindow);
119121
void setUserDataPaths(QString dir);
120122
void returnSteamDir();
121123
void writeVDF();

0 commit comments

Comments
 (0)