Added to store last used page for post creation

Added to store last used page for post creation
This commit is contained in:
defnax 2020-02-12 18:23:58 +01:00
parent 48e8dc5c8c
commit bedd2d36d4
3 changed files with 120 additions and 43 deletions

View File

@ -22,6 +22,8 @@
#include <QMessageBox>
#include <QByteArray>
#include <QStringList>
#include <QSignalMapper>
#include "PostedCreatePostDialog.h"
#include "ui_PostedCreatePostDialog.h"
@ -35,10 +37,13 @@
#include <QBuffer>
#include <iostream>
#include <gui/RetroShareLink.h>
#include <util/imageutil.h>
#include <gui/RetroShareLink.h>
/* View Page */
#define VIEW_POST 1
#define VIEW_IMAGE 2
#define VIEW_LINK 3
PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *posted, const RsGxsGroupId& grpId, QWidget *parent):
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint),
@ -67,6 +72,16 @@ PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *pos
/* fill in the available OwnIds for signing */
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
QSignalMapper *signalMapper = new QSignalMapper(this);
connect(ui->postButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->imageButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->linkButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
signalMapper->setMapping(ui->postButton, VIEW_POST);
signalMapper->setMapping(ui->imageButton, VIEW_IMAGE);
signalMapper->setMapping(ui->linkButton, VIEW_LINK);
connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(setPage(int)));
ui->removeButton->hide();
/* load settings */
@ -93,11 +108,17 @@ void PostedCreatePostDialog::processSettings(bool load)
// state of ID Chooser combobox
int index = Settings->value("IDChooser", 0).toInt();
ui->idChooser->setCurrentIndex(index);
// load last used Stacked Page
setPage(Settings->value("viewPage", VIEW_POST).toInt());
} else {
// save settings
// state of ID Chooser combobox
Settings->setValue("IDChooser", ui->idChooser->currentIndex());
// store last used Page
Settings->setValue("viewPage", viewMode());
}
Settings->endGroup();
@ -222,19 +243,51 @@ void PostedCreatePostDialog::addPicture()
}
void PostedCreatePostDialog::on_postButton_clicked()
int PostedCreatePostDialog::viewMode()
{
ui->stackedWidget->setCurrentIndex(0);
if (ui->postButton->isChecked()) {
return VIEW_POST;
} else if (ui->imageButton->isChecked()) {
return VIEW_IMAGE;
} else if (ui->linkButton->isChecked()) {
return VIEW_LINK;
}
/* Default */
return VIEW_POST;
}
void PostedCreatePostDialog::on_imageButton_clicked()
void PostedCreatePostDialog::setPage(int viewMode)
{
ui->stackedWidget->setCurrentIndex(1);
}
switch (viewMode) {
case VIEW_POST:
ui->stackedWidget->setCurrentIndex(0);
void PostedCreatePostDialog::on_linkButton_clicked()
{
ui->stackedWidget->setCurrentIndex(2);
ui->postButton->setChecked(true);
ui->imageButton->setChecked(false);
ui->linkButton->setChecked(false);
break;
case VIEW_IMAGE:
ui->stackedWidget->setCurrentIndex(1);
ui->imageButton->setChecked(true);
ui->postButton->setChecked(false);
ui->linkButton->setChecked(false);
break;
case VIEW_LINK:
ui->stackedWidget->setCurrentIndex(2);
ui->linkButton->setChecked(true);
ui->postButton->setChecked(false);
ui->imageButton->setChecked(false);
break;
default:
setPage(VIEW_POST);
return;
}
}
void PostedCreatePostDialog::on_removeButton_clicked()

View File

@ -52,14 +52,13 @@ private:
private slots:
void createPost();
void addPicture();
void on_postButton_clicked();
void on_imageButton_clicked();
void on_linkButton_clicked();
void on_removeButton_clicked();
void fileHashingFinished(QList<HashedFile> hashedFiles);
void setPage(int viewMode);
private:
void processSettings(bool load);
int viewMode();
QString mLink;
QString mNotes;

View File

@ -246,36 +246,7 @@
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="imageLabel">
<property name="maximumSize">
<size>
<width>800</width>
<height>200</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>188</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="1" column="2">
<widget class="QToolButton" name="removeButton">
<property name="toolTip">
<string>Remove image</string>
@ -295,6 +266,42 @@
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>188</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="shareimagecheckBox">
<property name="text">
<string>Share Orginal Image</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="imageLabel">
<property name="maximumSize">
<size>
<width>800</width>
<height>200</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -418,6 +425,9 @@
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -435,6 +445,15 @@
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
<item>
@ -452,6 +471,12 @@
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>