patterncppMinor
Tool to prepare custom screenshots for uploading to Steam Cloud
Viewed 0 times
screenshotsuploadingcloudsteamcustomforpreparetool
Problem
I've recently released my first ever Qt application, and would be glad if someone will look into it and tell me if there are some flagrant anti-patterns and likes.
This grabs some screenshots (paths) from the user and copies them to respective Steam directories, converting them to JPEG if necessary. After the copying it registers them in Steam's special screenshots.vdf file. The interface is shown here. After all this is done, the user can open Steam, go to the Screenshot Uploader there and find all the new screenshots available for uploading to the Steam Cloud.
I haven't designed my app. I just started to write it and the design started to form. This is horrendous, I know, but that's how I did it.
Anyway, the tool works on every supported platform and seems like doing its job well.
The code is hosted on GitHub.
mainwindow.h
```
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include
#include
#include
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private slots:
void warnOnMissingVDF();
void getGameNames(QNetworkReply *reply);
void on_pushButtonLocateSteamDir_clicked();
void on_pushButtonAddScreenshots_clicked();
void on_pushButtonClearQueue_clicked();
void on_pushButtonCopyScreenshots_clicked();
void on_pushButtonPrepare_clicked();
signals:
void vdfIsMissing();
private:
Ui::MainWindow *ui;
void setUserDataPaths(QString dir);
void writeSettings();
void readSettings();
void populateScreenshotQueue(QStringList screenshotPathsList);
void disableAllOnMissingSteamDir();
void pushScreenshots();
void toggleLabelInfo(bool isVisible);
QString convertSlashes(QString str);
QStringList readVDF();
void writeVDF(QStringList lines);
#if defined(Q_OS_WIN32)
This grabs some screenshots (paths) from the user and copies them to respective Steam directories, converting them to JPEG if necessary. After the copying it registers them in Steam's special screenshots.vdf file. The interface is shown here. After all this is done, the user can open Steam, go to the Screenshot Uploader there and find all the new screenshots available for uploading to the Steam Cloud.
I haven't designed my app. I just started to write it and the design started to form. This is horrendous, I know, but that's how I did it.
Anyway, the tool works on every supported platform and seems like doing its job well.
The code is hosted on GitHub.
mainwindow.h
```
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include
#include
#include
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private slots:
void warnOnMissingVDF();
void getGameNames(QNetworkReply *reply);
void on_pushButtonLocateSteamDir_clicked();
void on_pushButtonAddScreenshots_clicked();
void on_pushButtonClearQueue_clicked();
void on_pushButtonCopyScreenshots_clicked();
void on_pushButtonPrepare_clicked();
signals:
void vdfIsMissing();
private:
Ui::MainWindow *ui;
void setUserDataPaths(QString dir);
void writeSettings();
void readSettings();
void populateScreenshotQueue(QStringList screenshotPathsList);
void disableAllOnMissingSteamDir();
void pushScreenshots();
void toggleLabelInfo(bool isVisible);
QString convertSlashes(QString str);
QStringList readVDF();
void writeVDF(QStringList lines);
#if defined(Q_OS_WIN32)
Solution
The entire
Thus, the
MainWindow class is too big. It's basically a God class that contains your whole program logic. As you've already tagged the question with design-patterns, one pattern to use would be Model-View-Controller or Model-View-Presenter. Thus, the
MainWindow only becomes responsible for displaying the UI and handling user inputs. Event handlers such as on_button_clicked do nothing more then notify a controller/presenter that something occurred. These in turn call methods on your model which to the actual stuff, and, optionally, notify the view to display something new in the UI.Context
StackExchange Code Review Q#143635, answer score: 2
Revisions (0)
No revisions yet.