Browse Source

choose a avatar when create a contact

pull/130/head
DenioD 4 years ago
parent
commit
5dbfe1e4ad
  1. 20
      application.qrc
  2. 0
      res/Denio.png
  3. 0
      res/Duke.png
  4. 0
      res/Garfield.png
  5. 0
      res/Hirsch.png
  6. 0
      res/Mickey.png
  7. 0
      res/Pinguin.png
  8. 0
      res/Popey.png
  9. 0
      res/Sharpee.png
  10. 0
      res/Snoopy.png
  11. BIN
      res/Unbenannt-4 Kopie.png
  12. 0
      res/Yoda.png
  13. 30
      src/addressbook.cpp
  14. 9
      src/addressbook.h
  15. 28
      src/addressbook.ui
  16. 2
      src/contactmodel.cpp
  17. 26
      src/mainwindow.cpp
  18. 1
      src/mainwindow.h
  19. 9
      src/settings.cpp
  20. 2
      src/settings.h

20
application.qrc

@ -12,16 +12,16 @@
<file>res/sdlogo.png</file>
<file>res/sdlogo2.png</file>
<file>res/Berg.png</file>
<file>res/denio.png</file>
<file>res/duke.png</file>
<file>res/sharpee.png</file>
<file>res/yoda.png</file>
<file>res/mickey.png</file>
<file>res/snoopy.png</file>
<file>res/popey.png</file>
<file>res/garfield.png</file>
<file>res/pinguin.png</file>
<file>res/hirsch.png</file>
<file>res/Denio.png</file>
<file>res/Duke.png</file>
<file>res/Sharpee.png</file>
<file>res/Yoda.png</file>
<file>res/Mickey.png</file>
<file>res/Snoopy.png</file>
<file>res/Popey.png</file>
<file>res/Garfield.png</file>
<file>res/Pinguin.png</file>
<file>res/Hirsch.png</file>
</qresource>
<qresource prefix="/img">
<file>res/hushdlogo.gif</file>

0
res/denio.png → res/Denio.png

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

0
res/duke.png → res/Duke.png

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

0
res/garfield.png → res/Garfield.png

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

0
res/hirsch.png → res/Hirsch.png

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

0
res/mickey.png → res/Mickey.png

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

0
res/pinguin.png → res/Pinguin.png

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

0
res/popey.png → res/Popey.png

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

0
res/sharpee.png → res/Sharpee.png

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

0
res/snoopy.png → res/Snoopy.png

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

BIN
res/Unbenannt-4 Kopie.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

0
res/yoda.png → res/Yoda.png

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 82 KiB

30
src/addressbook.cpp

@ -169,7 +169,10 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
auto myAddr = ab.addr_chat->text().trimmed();
QString newLabel = ab.label->text();
QString cid = ab.cid->text();
QString avatar = "res/yoda.png";
QString avatar = QString("res/") + ab.comboBoxAvatar->currentText() + QString(".png");
qDebug()<<"AVATAR NAME : " << avatar;
if (addr.isEmpty() || newLabel.isEmpty())
{
@ -332,11 +335,34 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
}
};
// Get Avatar Data
// int avatar_index = ab.comboBoxAvatar->findText(AddressBook::getInstance()->get_avatar_name(), Qt::MatchExactly);
// ab.comboBoxAvatar->setCurrentIndex(avatar_index);
// QObject::connect(ab.comboBoxAvatar, &QComboBox::currentTextChanged, [=] (QString avatar_name) {
// parent->slot_change_avatar(avatar_name);
// rpc->refresh(true);
// });
// Refresh after the dialog is closed to update the labels everywhere.
parent->getRPC()->refresh(true);
model.updateUi(); //todo fix updating gui after adding
}
QString AddressBook::get_avatar_name() {
// Load from the QT Settings.
// QString avatar = ab.comboBoxAvatar.text();
// return QString()
}
void AddressBook::set_avatar_name(QString avatar_name) {
avatar_name = "abs.comboBoxAvatar.text()";
}
//=============
// AddressBook singleton class
//=============
@ -515,6 +541,8 @@ QString AddressBook::addLabelToAddress(QString addr)
return addr;
}
QString AddressBook::addressFromAddressLabel(const QString& lblAddr)
{
return lblAddr.trimmed().split("/").last();

9
src/addressbook.h

@ -22,6 +22,7 @@ public:
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
private:
void loadData();
@ -58,6 +59,14 @@ public:
QString getLabelForAddress(QString address);
// Get a Label's address
QString getAddressForLabel(QString label);
QString get_avatar_name();
void set_avatar_name(QString avatar_name);
private:
AddressBook();

28
src/addressbook.ui

@ -69,7 +69,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/hirsch.png</activeon>
<activeon>:/icons/res/Hirsch.png</activeon>
</iconset>
</property>
</item>
@ -79,7 +79,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/denio.png</activeon>
<activeon>:/icons/res/Denio.png</activeon>
</iconset>
</property>
</item>
@ -89,7 +89,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/duke.png</activeon>
<activeon>:/icons/res/Duke.png</activeon>
</iconset>
</property>
</item>
@ -99,7 +99,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/yoda.png</activeon>
<activeon>:/icons/res/Yoda.png</activeon>
</iconset>
</property>
</item>
@ -119,7 +119,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/sharpee.png</activeon>
<activeon>:/icons/res/Sharpee.png</activeon>
</iconset>
</property>
</item>
@ -129,7 +129,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/garfield.png</activeon>
<activeon>:/icons/res/Garfield.png</activeon>
</iconset>
</property>
</item>
@ -139,7 +139,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/snoopy.png</activeon>
<activeon>:/icons/res/Snoopy.png</activeon>
</iconset>
</property>
</item>
@ -149,7 +149,7 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/popey.png</activeon>
<activeon>:/icons/res/Popey.png</activeon>
</iconset>
</property>
</item>
@ -159,7 +159,17 @@
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/pinguin.png</activeon>
<activeon>:/icons/res/Pinguin.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Mickey</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Mickey.png</activeon>
</iconset>
</property>
</item>

2
src/contactmodel.cpp

@ -13,7 +13,7 @@ void ContactModel::renderContactList(QListView* view)
if ((theme == "dark" || theme == "midnight")) {
// QIcon avatar = c.getAvatar();
QString avatar = "res/yoda.png";
QString avatar = c.getAvatar();
QStandardItem* Items1 = new QStandardItem(QIcon(avatar) ,c.getName());
contact->appendRow(Items1);

26
src/mainwindow.cpp

@ -436,7 +436,9 @@ void MainWindow::setupSettingsModal() {
this->slot_change_currency(currency_name);
;
// Include Avatar
// Setup theme combo
@ -461,7 +463,7 @@ void MainWindow::setupSettingsModal() {
// Tell the user to restart
QMessageBox::information(this, tr("Currency Change"), tr("This change can take a few seconds."), QMessageBox::Ok);
});
// Check for updates
settings.chkCheckUpdates->setChecked(Settings::getInstance()->getCheckForUpdates());
@ -1468,6 +1470,26 @@ void MainWindow::slot_change_currency(const QString& currency_name)
}
}
void MainWindow::slot_change_avatar(const QString& avatar_name)
{
AddressBook::getInstance()->set_avatar_name(avatar_name);
// Include currency
QString saved_avatar_name;
try
{
saved_avatar_name = AddressBook::getInstance()->get_avatar_name();
}
catch (...)
{
saved_avatar_name = "Yoda";
}
}
void MainWindow::slot_change_theme(const QString& theme_name)

1
src/mainwindow.h

@ -83,6 +83,7 @@ public:
public slots:
void slot_change_theme(const QString& themeName);
void slot_change_currency(const QString& currencyName);
void slot_change_avatar(const QString& avatarName);
private:
void closeEvent(QCloseEvent* event);

9
src/settings.cpp

@ -225,13 +225,9 @@ QString Settings::get_currency_name() {
}
void Settings::set_currency_name(QString currency_name) {
QSettings().setValue("options/currency_name", currency_name);
QSettings().setValue("options/currency_name", currency_name);
}
QString Settings::get_theme_name() {
// Load from the QT Settings.
return QSettings().value("options/theme_name", false).toString();
@ -242,6 +238,9 @@ void Settings::set_theme_name(QString theme_name) {
}
//=================================
// Static Stuff
//=================================

2
src/settings.h

@ -67,6 +67,8 @@ public:
void set_currency_name(QString currency_name);
bool isSaplingActive();
void setZECPrice(double p) { ZECPrice = p; }

Loading…
Cancel
Save