primitive color picker, asset form
This commit is contained in:
parent
9a5a0b27a2
commit
374551d2bb
12 changed files with 207 additions and 57 deletions
10
API/api.cpp
10
API/api.cpp
|
@ -111,12 +111,18 @@ API::RequestId API::requestCurrencies (const SuccessListHandler& success, const
|
|||
return registerAndSend(std::move(list));
|
||||
}
|
||||
|
||||
API::RequestId API::addAsset (const QString& title, const QString& icon, const QColor& color, const QJSValue& finished) {
|
||||
API::RequestId API::addAsset (
|
||||
const QString& title,
|
||||
const QString& icon,
|
||||
const QColor& color,
|
||||
Models::Currency::ID currency,
|
||||
const QJSValue& finished
|
||||
) {
|
||||
qDebug() << "Adding asset...";
|
||||
if (magpie.getState() != Models::Magpie::Authenticated)
|
||||
return callCallback(finished, "Can not add assets in current state"), 0;
|
||||
|
||||
auto add = std::make_unique<Request::AddAsset>(title, icon, color, 1, magpie.getAddress());
|
||||
auto add = std::make_unique<Request::AddAsset>(title, icon, color, currency, magpie.getAddress());
|
||||
add->setAuthorizationToken(magpie.getAccessToken());
|
||||
connect(add.get(), &Request::AddAsset::success, std::bind(&API::callCallback, this, finished, QString(), QJSValueList{QJSValue(true)}));
|
||||
connect(add.get(), &Request::AddAsset::error, std::bind(&API::callCallback, this, finished, std::placeholders::_1, QJSValueList{QJSValue(false)}));
|
||||
|
|
|
@ -40,7 +40,13 @@ public slots:
|
|||
RequestId test(const QString& path, const QJSValue& finished = QJSValue());
|
||||
RequestId sendRegister(const QString& login, const QString& password, const QJSValue& finished = QJSValue());
|
||||
RequestId sendLogin(const QString& login, const QString& password, const QJSValue& finished = QJSValue());
|
||||
RequestId addAsset(const QString& title, const QString& icon, const QColor& color, const QJSValue& finished = QJSValue());
|
||||
RequestId addAsset(
|
||||
const QString& title,
|
||||
const QString& icon,
|
||||
const QColor& color,
|
||||
Models::Currency::ID currency,
|
||||
const QJSValue& finished = QJSValue()
|
||||
);
|
||||
RequestId deleteAsset(unsigned int id, const QJSValue& finished = QJSValue());
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -3,13 +3,16 @@
|
|||
|
||||
#include "addasset.h"
|
||||
|
||||
Request::AddAsset::AddAsset (const QString& title, const QString& icon, const QColor& color, unsigned int currency, const QUrl& baseUrl):
|
||||
Request::AddAsset::AddAsset (
|
||||
const QString& title,
|
||||
const QString& icon,
|
||||
const QColor& color,
|
||||
Models::Currency::ID currency,
|
||||
const QUrl& baseUrl
|
||||
):
|
||||
Post(createUrl(baseUrl, "/addAsset"), {
|
||||
{"title", title},
|
||||
{"icon", icon},
|
||||
{"currency", std::to_string(currency).c_str()},
|
||||
{"color", std::to_string(color.rgba()).c_str()}
|
||||
})
|
||||
{"title", title}, {"icon", icon}, {"currency", std::to_string(currency).c_str()}, {"color", std::to_string(color.rgba()).c_str()}
|
||||
})
|
||||
{
|
||||
emptyResult = true;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <QColor>
|
||||
|
||||
#include "post.h"
|
||||
#include "models/currencies.h"
|
||||
|
||||
namespace Request {
|
||||
|
||||
|
@ -13,7 +14,13 @@ class AddAsset : public Post {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AddAsset (const QString& title, const QString& icon, const QColor& color, unsigned int currency, const QUrl& baseUrl);
|
||||
AddAsset (
|
||||
const QString& title,
|
||||
const QString& icon,
|
||||
const QColor& color,
|
||||
Models::Currency::ID currency,
|
||||
const QUrl& baseUrl
|
||||
);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue