Skip to content

Commit

Permalink
Added rough infrastructure for sending board dimensions on upload.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kjell Morgenstern authored and KjellMorgenstern committed Dec 12, 2023
1 parent cc8f1b1 commit bdd117e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
25 changes: 24 additions & 1 deletion src/dialogs/fabuploaddialog.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*******************************************************************
Part of the Fritzing project - http://fritzing.org
Copyright (c) 2023 Fritzing GmbH
Fritzing 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.
Fritzing 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 Fritzing. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/

#include "fabuploaddialog.h"
#include "networkhelper.h"
#include "qstyle.h"
Expand All @@ -12,6 +32,9 @@

FabUploadDialog::FabUploadDialog(QNetworkAccessManager *manager,
QString filename,
double width,
double height,
int boardCount,
QWidget *parent) :
QDialog(parent),
ui(new Ui::FabUploadDialog),
Expand All @@ -21,7 +44,7 @@ FabUploadDialog::FabUploadDialog(QNetworkAccessManager *manager,
ui->setupUi(this);
setWindowFlags(Qt::Dialog | windowFlags());
ui->stackedWidget->setCurrentIndex(0);
ui->upload->init(manager, filename);
ui->upload->init(manager, filename, width, height, boardCount);
ui->uploadButton_2->setEnabled(false);

requestFabInfo();
Expand Down
5 changes: 3 additions & 2 deletions src/dialogs/fabuploaddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class FabUploadDialog : public QDialog
public:
explicit FabUploadDialog(QNetworkAccessManager* manager,
QString filename,
// double area,
// double boardCount,
double width,
double height,
int boardCount,
QWidget *parent = nullptr);
~FabUploadDialog();

Expand Down
9 changes: 8 additions & 1 deletion src/dialogs/fabuploadprogress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ FabUploadProgress::FabUploadProgress(QWidget *parent) : QWidget(parent)
{
}

void FabUploadProgress::init(QNetworkAccessManager *manager, QString filename)
void FabUploadProgress::init(QNetworkAccessManager *manager, QString filename,
double width, double height, int boardCount)
{
mManager = manager;
mFilepath = filename;
mWidth = width;
mHeight = height;
mBoardCount = boardCount;
}

void FabUploadProgress::doUpload()
Expand All @@ -55,6 +59,9 @@ void FabUploadProgress::doUpload()
QUrlQuery query;
QString fritzingVersion = Version::versionString();
query.addQueryItem("fritzing_version", fritzingVersion);
query.addQueryItem("width", QString::number(mWidth));
query.addQueryItem("height", QString::number(mHeight));
query.addQueryItem("board_count", QString::number(mBoardCount));

settings.beginGroup("sketches");
QVariant settingValue = settings.value(mFilepath);
Expand Down
25 changes: 24 additions & 1 deletion src/dialogs/fabuploadprogress.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*******************************************************************
Part of the Fritzing project - http://fritzing.org
Copyright (c) 2023 Fritzing GmbH
Fritzing 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.
Fritzing 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 Fritzing. If not, see <http://www.gnu.org/licenses/>.
********************************************************************/

#ifndef FABUPLOADPROGRESS_H
#define FABUPLOADPROGRESS_H

Expand All @@ -9,7 +29,7 @@ class FabUploadProgress : public QWidget
Q_OBJECT
public:
explicit FabUploadProgress(QWidget *parent = nullptr);
void init(QNetworkAccessManager *manager, QString filename);
void init(QNetworkAccessManager *manager, QString filename, double width, double height, int boardCount);

public Q_SLOTS:
void doUpload();
Expand All @@ -32,6 +52,9 @@ private Q_SLOTS:
QNetworkAccessManager *mManager;
QString mFilepath;
QString mRedirect_url;
double mWidth;
double mHeight;
int mBoardCount;

void uploadMultipart(const QUrl &url, const QString &file_path);
void checkProcessingStatus(QUrl url);
Expand Down
5 changes: 4 additions & 1 deletion src/mainwindow/mainwindow_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4473,7 +4473,10 @@ void MainWindow::orderFab()
}
// upload
auto* manager = new QNetworkAccessManager();
FabUploadDialog upload(manager, m_fwFilename, this);
int boardCount;
double width, height;
// m_pcbGraphicsView->calcBoardDimensions(boardCount, width, height);
FabUploadDialog upload(manager, m_fwFilename, width, height, boardCount, this);
upload.exec();
delete manager;
} else {
Expand Down

0 comments on commit bdd117e

Please sign in to comment.