feat: use Meui.Toast

master
ChungZH 2021-02-21 10:54:27 +08:00
parent c6fffc069f
commit 9f8896bdb3
3 changed files with 14 additions and 1 deletions

View File

@ -41,11 +41,13 @@ void Memory::increase(const QString &curNum) {
int temp = m_text.toInt(&success);
if (!success) {
qDebug() << "Failed to increase memory: String to int conversion failed. (m_text)";
emit failed("Failed to increase memory: String to int conversion failed.");
return;
}
int temp2 = curNum.toInt(&success);
if (!success) {
qDebug() << "Failed to increase memory: String to int conversion failed. (curNum)";
emit failed("Failed to increase memory: String to int conversion failed.");
return;
}
temp += temp2;
@ -59,11 +61,13 @@ void Memory::decrease(const QString &curNum) {
int temp = m_text.toInt(&success);
if (!success) {
qDebug() << "Failed to decrease memory: String to int conversion failed. (m_text)";
emit failed("Failed to decrease memory: String to int conversion failed.");
return;
}
int temp2 = curNum.toInt(&success);
if (!success) {
qDebug() << "Failed to increase memory: String to int conversion failed. (curNum)";
qDebug() << "Failed to decrease memory: String to int conversion failed. (curNum)";
emit failed("Failed to decrease memory: String to int conversion failed.");
return;
}
temp -= temp2;

View File

@ -42,6 +42,7 @@ public:
signals:
void textChanged();
void failed(const QString &errorString);
private:
QString m_text;

View File

@ -64,6 +64,14 @@ Item {
Memory {
id: memory
onFailed: {
toast.text = errorString
toast.open = true
}
}
Meui.Toast {
id: toast
}
function appendToTextField(text) {