mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
To-Do app: Improvements
This commit is contained in:
parent
377cbe31f1
commit
621dca8c41
5 changed files with 94 additions and 15 deletions
|
@ -398,6 +398,7 @@ void apps::showFailedToParseMainUserAppsJsonFile() {
|
|||
void apps::on_todoLaunchBtn_clicked()
|
||||
{
|
||||
todo * todoWindow = new todo();
|
||||
QObject::connect(todoWindow, &todo::showToast, this, &apps::showToast);
|
||||
todoWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
todoWindow->setGeometry(QRect(QPoint(0,0), qApp->primaryScreen()->geometry().size()));
|
||||
todoWindow->show();
|
||||
|
|
|
@ -24,12 +24,16 @@ todo::todo(QWidget *parent) :
|
|||
ui->deleteItemBtn->setProperty("type", "borderless");
|
||||
ui->selectAllItemsBtn->setProperty("type", "borderless");
|
||||
ui->selectItemsModeBtn->setProperty("type", "borderless");
|
||||
ui->deselectAllItemsBtn->setProperty("type", "borderless");
|
||||
ui->saveCurrentListViewBtn->setProperty("type", "borderless");
|
||||
ui->deleteBtn->setStyleSheet("padding: 10px");
|
||||
ui->setupBtn->setStyleSheet("padding: 10px");
|
||||
ui->newItemBtn->setStyleSheet("padding: 10px");
|
||||
ui->deleteItemBtn->setStyleSheet("padding: 10px");
|
||||
ui->selectAllItemsBtn->setStyleSheet("padding: 10px");
|
||||
ui->selectItemsModeBtn->setStyleSheet("padding: 10px");
|
||||
ui->deselectAllItemsBtn->setStyleSheet("padding: 10px");
|
||||
ui->saveCurrentListViewBtn->setStyleSheet("padding: 10px");
|
||||
ui->closeBtn->setIcon(QIcon(":/resources/close.png"));
|
||||
ui->newBtn->setIcon(QIcon(":/resources/new.png"));
|
||||
ui->newItemBtn->setIcon(QIcon(":/resources/plus.png"));
|
||||
|
@ -38,6 +42,8 @@ todo::todo(QWidget *parent) :
|
|||
ui->deleteItemBtn->setIcon(QIcon(":/resources/x-circle.png"));
|
||||
ui->selectAllItemsBtn->setIcon(QIcon(":/resources/checkbox-checked-small.png"));
|
||||
ui->selectItemsModeBtn->setIcon(QIcon(":/resources/checkbox-unchecked-small.png"));
|
||||
ui->deselectAllItemsBtn->setIcon(QIcon(":/resources/checkbox-x-small.png"));
|
||||
ui->saveCurrentListViewBtn->setIcon(QIcon(":/resources/save.png"));
|
||||
ui->listWidget->setStyleSheet("font-size: 10pt");
|
||||
ui->listWidget->setWordWrap(true);
|
||||
ui->itemsListWidget->setStyleSheet("font-size: 10pt");
|
||||
|
@ -290,18 +296,31 @@ void todo::switchItemsSelectionMode(bool selectionMode) {
|
|||
|
||||
void todo::on_deleteItemBtn_clicked()
|
||||
{
|
||||
log("Deleting list item(s)", className);
|
||||
QList<int> itemsToDelete;
|
||||
for(int i = 1; i < ui->itemsListWidget->count() + 1; i++) {
|
||||
if(ui->itemsListWidget->item(i - 1)->checkState() == Qt::Checked) {
|
||||
itemsToDelete.append(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(!itemsToDelete.isEmpty()) {
|
||||
QString itemsToDeleteString;
|
||||
for(int i = 0; i < itemsToDelete.count(); i++) {
|
||||
itemsToDeleteString.append(QString::number(itemsToDelete[i]));
|
||||
if(i < itemsToDelete.count() - 1) {
|
||||
itemsToDeleteString.append(", ");
|
||||
}
|
||||
}
|
||||
log("Deleting list item(s) " + itemsToDeleteString, className);
|
||||
QJsonDocument document = readTodoDatabase();
|
||||
QJsonObject object = document.object();
|
||||
QJsonArray mainArray = object["List"].toArray();
|
||||
QJsonArray listArray = mainArray.at(listIndex).toArray();
|
||||
int itemsRemoved = 0;
|
||||
for(int i = 1; i < ui->itemsListWidget->count() + 1; i++) {
|
||||
if(ui->itemsListWidget->item(i - 1)->checkState() == Qt::Checked) {
|
||||
listArray.removeAt(i - itemsRemoved);
|
||||
for(int i = 0; i < itemsToDelete.count(); i++) {
|
||||
listArray.removeAt(itemsToDelete.at(i) - itemsRemoved);
|
||||
itemsRemoved++;
|
||||
}
|
||||
}
|
||||
|
||||
// Adding item array to list array
|
||||
mainArray.replace(listIndex, listArray);
|
||||
|
@ -312,6 +331,10 @@ void todo::on_deleteItemBtn_clicked()
|
|||
|
||||
setupList(listArray.at(0).toString());
|
||||
}
|
||||
else {
|
||||
emit showToast("No item(s) selected");
|
||||
}
|
||||
}
|
||||
|
||||
void todo::on_selectAllItemsBtn_clicked()
|
||||
{
|
||||
|
@ -328,3 +351,17 @@ void todo::setDefaultHomePageStatusText() {
|
|||
void todo::setDefaultListPageStatusText() {
|
||||
ui->statusLabel->setText("Select or create a new item");
|
||||
}
|
||||
|
||||
void todo::on_deselectAllItemsBtn_clicked()
|
||||
{
|
||||
int range = ui->itemsListWidget->count();
|
||||
for(int i = 0; i < range; i++) {
|
||||
ui->itemsListWidget->item(i)->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
void todo::on_saveCurrentListViewBtn_clicked()
|
||||
{
|
||||
saveCurrentList();
|
||||
switchItemsSelectionMode(false);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,11 @@ private slots:
|
|||
void on_selectItemsModeBtn_clicked();
|
||||
void on_deleteItemBtn_clicked();
|
||||
void on_selectAllItemsBtn_clicked();
|
||||
void on_deselectAllItemsBtn_clicked();
|
||||
void on_saveCurrentListViewBtn_clicked();
|
||||
|
||||
signals:
|
||||
void showToast(QString messageToDisplay);
|
||||
|
||||
private:
|
||||
Ui::todo *ui;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<width>483</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -309,6 +309,40 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_9">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="deselectAllItemsBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_10">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="saveCurrentListViewBtn">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -101,5 +101,7 @@
|
|||
<file>resources/new.png</file>
|
||||
<file>resources/checkbox-unchecked-small.png</file>
|
||||
<file>resources/checkbox-checked-small.png</file>
|
||||
<file>resources/checkbox-x-small.png</file>
|
||||
<file>resources/checkbox-x.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in a new issue