From 9e4903c9b80ebb5c0f6101ea96c9fab51b6db4ae Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 15 Jan 2022 15:19:05 +0100 Subject: [PATCH] Add General Font Size Factor --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 167 +++++++++--------- retroshare-gui/src/gui/ChatLobbyWidget.h | 10 +- .../src/gui/FileTransfer/TransfersDialog.cpp | 74 ++++---- retroshare-gui/src/gui/FriendsDialog.cpp | 28 +-- retroshare-gui/src/gui/HomePage.cpp | 40 ++--- retroshare-gui/src/gui/Identity/IdDialog.cpp | 28 +-- retroshare-gui/src/gui/MainPage.cpp | 16 +- retroshare-gui/src/gui/NewsFeed.cpp | 34 ++-- .../src/gui/Posted/PostedDialog.cpp | 22 ++- .../src/gui/gxschannels/GxsChannelDialog.cpp | 68 +++---- .../src/gui/gxsforums/GxsForumsDialog.cpp | 23 ++- .../src/gui/msgs/MessagesDialog.cpp | 25 +-- retroshare-gui/src/util/misc.cpp | 98 +++++----- retroshare-gui/src/util/misc.h | 22 ++- 14 files changed, 345 insertions(+), 310 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 13fdc4329..0b5350110 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -22,19 +22,20 @@ #include "ChatLobbyWidget.h" #include "notifyqt.h" +#include "RetroShareLink.h" #include "chat/ChatLobbyDialog.h" #include "chat/ChatLobbyUserNotify.h" #include "chat/ChatTabWidget.h" #include "chat/CreateLobbyDialog.h" +#include "common/FilesDefs.h" #include "common/RSTreeWidgetItem.h" #include "common/RSElidedItemDelegate.h" -#include "gui/RetroShareLink.h" -#include "gui/gxs/GxsIdDetails.h" -#include "gui/Identity/IdEditDialog.h" -#include "gui/settings/rsharesettings.h" +#include "gxs/GxsIdDetails.h" +#include "Identity/IdEditDialog.h" +#include "settings/rsharesettings.h" #include "util/HandleRichText.h" +#include "util/misc.h" #include "util/QtVersion.h" -#include "gui/common/FilesDefs.h" #include "retroshare/rsmsgs.h" #include "retroshare/rspeers.h" @@ -206,28 +207,29 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) // load settings processSettings(true); - QString help_str = tr("\ -

  Chat Rooms

\ -

Chat rooms work pretty much like IRC. \ - They allow you to talk anonymously with tons of people without the need to make friends.

\ -

A chat room can be public (your friends see it) or private (your friends can't see it, unless you \ - invite them with ). \ - Once you have been invited to a private room, you will be able to see it when your friends \ - are using it.

\ -

The list at left shows \ - chat lobbies your friends are participating in. You can either \ -

\ - Note: For the chat rooms to work properly, your computer needs be on time. So check your system clock!\ -

\ - " - ).arg(QString::number(4*W), QString::number(2*W)) ; + int hbH = misc::getFontSizeFactor("HelpButton").height(); + QString help_str = tr( + "

  Chat Rooms

" + "

Chat rooms work pretty much like IRC." + " They allow you to talk anonymously with tons of people without the need to make friends.

" + "

A chat room can be public (your friends see it) or private (your friends can't see it, unless you" + " invite them with )." + " Once you have been invited to a private room, you will be able to see it when your friends" + " are using it.

" + "

The list at left shows" + " chat lobbies your friends are participating in. You can either" + "

" + " Note: For the chat rooms to work properly, your computer needs be on time. So check your system clock!" + "

" + ).arg(QString::number(2*hbH), QString::number(hbH)) ; registerHelpButton(ui.helpButton,help_str,"ChatLobbyDialog") ; - - ui.lobbyTreeWidget->setIconSize(QSize(H*1.5,H*1.5)); + + int ltwH = misc::getFontSizeFactor("LobbyTreeWidget", 1.5).height(); + ui.lobbyTreeWidget->setIconSize(QSize(ltwH,ltwH)); } ChatLobbyWidget::~ChatLobbyWidget() @@ -293,87 +295,84 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) QMenu contextMnu(this); if (item && item->type() == TYPE_FOLDER) { - QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CREATE), tr("Create chat room"), this, SLOT(createChatLobby())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CREATE), tr("Create chat room"), this, SLOT(createChatLobby())); action->setData(item->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt()); } - if (item && item->type() == TYPE_LOBBY) - { - std::list own_identities ; - rsIdentity->getOwnIds(own_identities) ; + if (item && item->type() == TYPE_LOBBY) + { + std::list own_identities ; + rsIdentity->getOwnIds(own_identities) ; - if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) - contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_UNSUBSCRIBE), tr("Leave this room"), this, SLOT(unsubscribeItem())); - else - { - QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); + if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_UNSUBSCRIBE), tr("Leave this room"), this, SLOT(unsubscribeItem())); + else + { + ChatLobbyFlags flags(item->data(COLUMN_DATA, ROLE_FLAGS).toUInt()); - //ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong(); - ChatLobbyFlags flags(item->data(COLUMN_DATA, ROLE_FLAGS).toUInt()); + bool removed = false ; + if(flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) + removed = trimAnonIds(own_identities) ; - bool removed = false ; - if(flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) - removed = trimAnonIds(own_identities) ; - - if(own_identities.empty()) - { - if(removed) - contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Create a non anonymous identity and enter this room"), this, SLOT(createIdentityAndSubscribe())); - else - contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Create an identity and enter this chat room"), this, SLOT(createIdentityAndSubscribe())); - } - else if(own_identities.size() == 1) - { - QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Enter this chat room"), this, SLOT(subscribeChatLobbyAs())); - action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; - } - else - { - QMenu *mnu = contextMnu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE),tr("Enter this chat room as...")) ; + if(own_identities.empty()) + { + if(removed) + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Create a non anonymous identity and enter this room"), this, SLOT(createIdentityAndSubscribe())); + else + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Create an identity and enter this chat room"), this, SLOT(createIdentityAndSubscribe())); + } + else if(own_identities.size() == 1) + { + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Enter this chat room"), this, SLOT(subscribeChatLobbyAs())); + action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; + } + else + { + QMenu *mnu = contextMnu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE),tr("Enter this chat room as...")) ; - for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) - { - RsIdentityDetails idd ; - rsIdentity->getIdDetails(*it,idd) ; + for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) + { + RsIdentityDetails idd ; + rsIdentity->getIdDetails(*it,idd) ; - QPixmap pixmap ; + QPixmap pixmap ; - if(idd.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idd.mAvatar.mData, idd.mAvatar.mSize, pixmap, GxsIdDetails::SMALL)) - pixmap = GxsIdDetails::makeDefaultIcon(*it,GxsIdDetails::SMALL) ; + if(idd.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idd.mAvatar.mData, idd.mAvatar.mSize, pixmap, GxsIdDetails::SMALL)) + pixmap = GxsIdDetails::makeDefaultIcon(*it,GxsIdDetails::SMALL) ; - QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(subscribeChatLobbyAs())); - action->setData(QString::fromStdString((*it).toStdString())) ; - } - } - } + QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(subscribeChatLobbyAs())); + action->setData(QString::fromStdString((*it).toStdString())) ; + } + } + } #ifdef TO_BE_REMOVED - // This code is not needed anymore because AutoSubscribe is now automatically handled with chat room subscription. + // This code is not needed anymore because AutoSubscribe is now automatically handled with chat room subscription. - if (item->data(COLUMN_DATA, ROLE_AUTOSUBSCRIBE).toBool()) - contextMnu.addAction(QIcon(IMAGE_AUTOSUBSCRIBE), tr("Remove Auto Subscribe"), this, SLOT(autoSubscribeItem())); - else if(!own_identities.empty()) - contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Add Auto Subscribe"), this, SLOT(autoSubscribeItem())); + if (item->data(COLUMN_DATA, ROLE_AUTOSUBSCRIBE).toBool()) + contextMnu.addAction(QIcon(IMAGE_AUTOSUBSCRIBE), tr("Remove Auto Subscribe"), this, SLOT(autoSubscribeItem())); + else if(!own_identities.empty()) + contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Add Auto Subscribe"), this, SLOT(autoSubscribeItem())); #endif - contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYRSLINK), tr("Copy RetroShare Link"), this, SLOT(copyItemLink())); - } + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYRSLINK), tr("Copy RetroShare Link"), this, SLOT(copyItemLink())); + } - contextMnu.addSeparator();//------------------------------------------------------------------- + contextMnu.addSeparator();//------------------------------------------------------------------- - showUserCountAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT)); - showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC)); + showUserCountAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_USER_COUNT)); + showTopicAct->setChecked(!ui.lobbyTreeWidget->isColumnHidden(COLUMN_TOPIC)); - QMenu *menu = contextMnu.addMenu(tr("Columns")); - menu->addAction(showUserCountAct); - menu->addAction(showTopicAct); + QMenu *menu = contextMnu.addMenu(tr("Columns")); + menu->addAction(showUserCountAct); + menu->addAction(showTopicAct); - contextMnu.exec(QCursor::pos()); + contextMnu.exec(QCursor::pos()); } void ChatLobbyWidget::lobbyChanged() { - updateDisplay(); + ChatLobbyWidget::updateDisplay(); } static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobbyId id, const std::string &name, const std::string &topic, int count, bool subscribed, bool autoSubscribe,ChatLobbyFlags lobby_flags) @@ -607,7 +606,7 @@ void ChatLobbyWidget::updateDisplay() QTreeWidgetItem *itemLoop = lobby_other_item->child(childIndex); if (itemLoop->type() == TYPE_LOBBY && itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == lobby.lobby_id) { delete(lobby_other_item->takeChild(lobby_other_item->indexOfChild(itemLoop))); - childCnt = lobby_other_item->childCount(); + //childCnt = lobby_other_item->childCount(); break; } } diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index a9bb01895..a5055788e 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -56,18 +56,18 @@ class ChatLobbyWidget : public RsAutoUpdatePage public: /** Default constructor */ - ChatLobbyWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0); + ChatLobbyWidget(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()); /** Default destructor */ ~ChatLobbyWidget(); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_CHATLOBBY) ; } //MainPage - virtual QString pageName() const { return tr("Chats") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage + virtual QIcon iconPixmap() const override { return QIcon(IMAGE_CHATLOBBY) ; } //MainPage + virtual QString pageName() const override { return tr("Chats") ; } //MainPage + virtual QString helpText() const override { return ""; } //MainPage virtual UserNotify *createUserNotify(QObject *parent) override; //MainPage - virtual void updateDisplay(); + virtual void updateDisplay() override; //RsAutoUpdatePage void setCurrentChatPage(ChatLobbyDialog *) ; // used by ChatLobbyDialog to raise. void addChatPage(ChatLobbyDialog *) ; diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index 9fa03f3fd..035ed2ca6 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -449,7 +449,7 @@ public: case COLUMN_SOURCES: { int active = 0; - QString fileHash = QString::fromStdString(fileInfo.hash.toStdString()); + //QString fileHash = QString::fromStdString(fileInfo.hash.toStdString()); if (fileInfo.downloadStatus != FT_STATE_COMPLETE) for (std::vector::const_iterator pit = fileInfo.peers.begin() ; pit != fileInfo.peers.end(); ++pit) @@ -635,27 +635,27 @@ public: for(auto it(downHashes.begin());it!=downHashes.end();++it,++i) { FileInfo fileInfo(mDownloads[i]); // we dont update the data itself but only a copy of it.... - int old_size = fileInfo.peers.size() ; + int old_peers_size = fileInfo.peers.size() ; rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, fileInfo); int new_size = fileInfo.peers.size() ; - if(old_size < new_size) + if(old_peers_size < new_size) { - beginInsertRows(index(i,0), old_size, new_size-1); - insertRows(old_size, new_size - old_size,index(i,0)); + beginInsertRows(index(i,0), old_peers_size, new_size-1); + insertRows(old_peers_size, new_size - old_peers_size,index(i,0)); #ifdef DEBUG_DOWNLOADLIST - std::cerr << "called insert rows ( " << old_size << ", " << new_size - old_size << ",index(" << index(i,0)<< "))" << std::endl; + std::cerr << "called insert rows ( " << old_peers_size << ", " << new_size - old_peers_size << ",index(" << index(i,0)<< "))" << std::endl; #endif endInsertRows(); } - else if(new_size < old_size) + else if(new_size < old_peers_size) { - beginRemoveRows(index(i,0), new_size, old_size-1); - removeRows(new_size, old_size - new_size,index(i,0)); + beginRemoveRows(index(i,0), new_size, old_peers_size-1); + removeRows(new_size, old_peers_size - new_size,index(i,0)); #ifdef DEBUG_DOWNLOADLIST - std::cerr << "called remove rows ( " << old_size << ", " << old_size - new_size << ",index(" << index(i,0)<< "))" << std::endl; + std::cerr << "called remove rows ( " << old_peers_size << ", " << old_peers_size - new_size << ",index(" << index(i,0)<< "))" << std::endl; #endif endRemoveRows(); } @@ -742,7 +742,7 @@ private: class SortByNameItem : public QStandardItem { public: - SortByNameItem(QHeaderView *header) : QStandardItem() + explicit SortByNameItem(QHeaderView *header) : QStandardItem() { this->header = header; } @@ -780,9 +780,9 @@ private: class ProgressItem : public SortByNameItem { public: - ProgressItem(QHeaderView *header) : SortByNameItem(header) {} + explicit ProgressItem(QHeaderView *header) : SortByNameItem(header) {} - virtual bool operator<(const QStandardItem &other) const + virtual bool operator<(const QStandardItem &other) const override { const int role = model() ? model()->sortRole() : Qt::DisplayRole; @@ -1077,24 +1077,23 @@ TransfersDialog::TransfersDialog(QWidget *parent) // load settings processSettings(true); - int S = static_cast(QFontMetricsF(font()).height()); + int H = misc::getFontSizeFactor("HelpButton").height(); QString help_str = tr( - "

  " - "File Transfer

" - "

Retroshare brings two ways of transferring files: direct " - "transfers from your friends, and distant anonymous tunnelled " - "transfers. In addition, file transfer is multi-source and " - "allows swarming (you can be a source while downloading)

" - "

You can share files using the " - "" - " icon from the left side bar. These files will be listed in " - "the My Files tab. You can decide for each friend group whether" - " they can or not see these files in their Friends Files tab

" - "

The search tab reports files from your friends' file lists," - " and distant files that can be reached anonymously using the " - "multi-hop tunnelling system.

") - .arg(QString::number(2*S)).arg(QString::number(S)) ; - + "

  " + " File Transfer

" + "

Retroshare brings two ways of transferring files: direct " + " transfers from your friends, and distant anonymous tunnelled " + " transfers. In addition, file transfer is multi-source and " + " allows swarming (you can be a source while downloading)

" + "

You can share files using the " + " " + " icon from the left side bar. These files will be listed in " + " the My Files tab. You can decide for each friend group whether" + " they can or not see these files in their Friends Files tab

" + "

The search tab reports files from your friends' file lists," + " and distant files that can be reached anonymously using the " + " multi-hop tunnelling system.

" + ).arg(QString::number(2*H), QString::number(H)) ; registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ; @@ -1584,7 +1583,6 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo) //unique combination: fileHash + peerId, variant: hash + peerName (too long) QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString()); - qlonglong completed = transferInfo.transfered; double peerULSpeed = transferInfo.tfRate * 1024.0; @@ -1602,6 +1600,7 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo) peerpinfo.type = FileProgressInfo::UPLOAD_LINE ; peerpinfo.nb_chunks = peerpinfo.cmap._map.empty()?0:nb_chunks ; + qlonglong completed = 0; if(filled_chunks > 0 && nb_chunks > 0) { completed = peerpinfo.cmap.computeProgress(fileInfo.size,chunk_size) ; @@ -1720,9 +1719,6 @@ void TransfersDialog::insertTransfers() { // Since downloads use an AstractItemModel, we just need to update it, while saving the selected and expanded items. - std::set expanded_hashes ; - std::set selected_hashes ; - DLListModel->update_transfers(); // Now show upload hashes. Here we use the "old" way, since the number of uploads is generally not so large. @@ -1957,16 +1953,16 @@ void TransfersDialog::pasteLink() RsCollection col ; RSLinkClipboard::pasteLinks(links,RetroShareLink::TYPE_FILE_TREE); - for(QList::const_iterator it(links.begin());it!=links.end();++it) + for(auto &it: links) { - auto ft = RsFileTree::fromRadix64((*it).radix().toStdString()); + auto ft = RsFileTree::fromRadix64(it.radix().toStdString()); col.merge_in(*ft); } links.clear(); RSLinkClipboard::pasteLinks(links,RetroShareLink::TYPE_FILE); - for(QList::const_iterator it(links.begin());it!=links.end();++it) - col.merge_in((*it).name(),(*it).size(),RsFileHash((*it).hash().toStdString())) ; + for(auto &it : links) + col.merge_in(it.name(),it.size(),RsFileHash(it.hash().toStdString())) ; col.downloadFiles(); } @@ -1985,7 +1981,7 @@ void TransfersDialog::getDLSelectedItems(std::set *ids, std::setindex(index.parent().row(), COLUMN_ID); if (ids) { diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index e3f74fcfd..5df97121a 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -127,21 +127,21 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) ui.nicknameLabel->setText(QString::fromUtf8(pd.name.c_str()) + " (" + QString::fromUtf8(pd.location.c_str())+")"); } - QString hlp_str = tr( - "

  Network

\ -

The Network tab shows your friend Retroshare nodes: the neighbor Retroshare nodes that are connected to you. \ -

\ -

You can group nodes together to allow a finer level of information access, for instance to only allow \ - some nodes to see some of your files.

\ -

On the right, you will find 3 useful tabs: \ -

    \ -
  • Broadcast sends messages to all connected nodes at once
  • \ -
  • Local network graph shows the network around you, based on discovery information
  • \ -
  • Keyring contains node keys you collected, mostly forwarded to you by your friend nodes
  • \ -

\ - ") ; + int H = misc::getFontSizeFactor("HelpButton").height(); + QString hlp_str = tr( + "

  Network

" + "

The Network tab shows your friend Retroshare nodes: the neighbor Retroshare nodes that are connected to you.

" + "

You can group nodes together to allow a finer level of information access, for instance to only allow" + " some nodes to see some of your files.

" + "

On the right, you will find 3 useful tabs:" + "

    " + "
  • Broadcast sends messages to all connected nodes at once
  • " + "
  • Local network graph shows the network around you, based on discovery information
  • " + "
  • Keyring contains node keys you collected, mostly forwarded to you by your friend nodes
  • " + "

" + ).arg(QString::number(2*H)); - registerHelpButton(ui.helpButton, hlp_str,"FriendsDialog") ; + registerHelpButton(ui.helpButton, hlp_str,"FriendsDialog") ; } FriendsDialog::~FriendsDialog () diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 6c1737076..ef6982e22 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -24,6 +24,7 @@ #include "retroshare/rsinit.h" #include "util/qtthreadsutils.h" +#include "util/misc.h" #include "gui/notifyqt.h" #include "gui/msgs/MessageComposer.h" @@ -100,21 +101,20 @@ HomePage::HomePage(QWidget *parent) : connect(ui->openwebhelp,SIGNAL(clicked()), this,SLOT(openWebHelp())) ; - int S = QFontMetricsF(font()).height(); - QString help_str = tr( - "

  Welcome to Retroshare!

\ -

You need to make friends! After you create a network of friends or join an existing network,\ - you'll be able to exchange files, chat, talk in forums, etc.

\ -
\ - \ -
\ -

To do so, copy your Retroshare ID on this page and send it to friends, and add your friends' Retroshare ID.

\ -

Another option is to search the internet for \"Retroshare chat servers\" (independently administrated). These servers allow you to exchange \ - Retroshare ID with a dedicated Retroshare node, through which\ - you will be able to anonymously meet other people.

").arg(QString::number(2*S)).arg(width()*0.5); - registerHelpButton(ui->helpButton,help_str,"HomePage") ; + int H = misc::getFontSizeFactor("HelpButton").height(); + QString help_str = tr( + "

  Welcome to Retroshare!

" + "

You need to make friends! After you create a network of friends or join an existing network," + " you'll be able to exchange files, chat, talk in forums, etc.

" + "
" + "

To do so, copy your Retroshare ID on this page and send it to friends, and add your friends' Retroshare ID.

" + "

Another option is to search the internet for \"Retroshare chat servers\" (independently administrated). These servers allow you to exchange" + " Retroshare ID with a dedicated Retroshare node, through which" + " you will be able to anonymously meet other people.

" + ).arg(QString::number(2*H), QString::number(width()*0.5), QString::number(width()*0.5*(337.0/800.0)));// needs height and width defined. + registerHelpButton(ui->helpButton,help_str,"HomePage") ; - // register a event handler to catch IP updates + // register a event handler to catch IP updates mEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK ); @@ -249,13 +249,8 @@ void HomePage::updateOwnCert() ui->retroshareid->setToolTip(description); } -static void sendMail(QString sAddress, QString sSubject, QString sBody) +static void sendMail(const QString &sAddress, const QString &sSubject, const QString &sBody) { -#ifdef Q_OS_WIN - /* search and replace the end of lines with: "%0D%0A" */ - sBody.replace("\n", "%0D%0A"); -#endif - QUrl url = QUrl("mailto:" + sAddress); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) @@ -265,7 +260,12 @@ static void sendMail(QString sAddress, QString sSubject, QString sBody) #endif urlQuery.addQueryItem("subject", sSubject); +#ifdef Q_OS_WIN + /* search and replace the end of lines with: "%0D%0A" */ + urlQuery.addQueryItem("body", QString(sBody).replace("\n", "%0D%0A")); +#else urlQuery.addQueryItem("body", sBody); +#endif #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) url.setQuery(urlQuery); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index a7536b048..c40bb0931 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -385,20 +385,22 @@ IdDialog::IdDialog(QWidget *parent) mStateHelper->setActive(IDDIALOG_IDDETAILS, false); mStateHelper->setActive(IDDIALOG_REPLIST, false); + int H = misc::getFontSizeFactor("HelpButton").height(); QString hlp_str = tr( - "

  Identities

\ -

In this tab you can create/edit pseudo-anonymous identities, and circles.

\ -

Identities are used to securely identify your data: sign messages in chat lobbies, forum and channel posts,\ - receive feedback using the Retroshare built-in email system, post comments \ - after channel posts, chat using secured tunnels, etc.

\ -

Identities can optionally be signed by your Retroshare node's certificate. \ - Signed identities are easier to trust but are easily linked to your node's IP address.

\ -

Anonymous identities allow you to anonymously interact with other users. They cannot be \ - spoofed, but noone can prove who really owns a given identity.

\ -

Circles are groups of identities (anonymous or signed), that are shared at a distance over the network. They can be \ - used to restrict the visibility to forums, channels, etc.

\ -

An circle can be restricted to another circle, thereby limiting its visibility to members of that circle \ - or even self-restricted, meaning that it is only visible to invited members.

") ; + "

  Identities

" + "

In this tab you can create/edit pseudo-anonymous identities, and circles.

" + "

Identities are used to securely identify your data: sign messages in chat lobbies, forum and channel posts," + " receive feedback using the Retroshare built-in email system, post comments" + " after channel posts, chat using secured tunnels, etc.

" + "

Identities can optionally be signed by your Retroshare node's certificate." + " Signed identities are easier to trust but are easily linked to your node's IP address.

" + "

Anonymous identities allow you to anonymously interact with other users. They cannot be" + " spoofed, but noone can prove who really owns a given identity.

" + "

Circles are groups of identities (anonymous or signed), that are shared at a distance over the network. They can be" + " used to restrict the visibility to forums, channels, etc.

" + "

An circle can be restricted to another circle, thereby limiting its visibility to members of that circle" + " or even self-restricted, meaning that it is only visible to invited members.

" + ).arg(QString::number(2*H)); registerHelpButton(ui->helpButton, hlp_str,"PeopleDialog") ; diff --git a/retroshare-gui/src/gui/MainPage.cpp b/retroshare-gui/src/gui/MainPage.cpp index 545f1270e..6136343d7 100644 --- a/retroshare-gui/src/gui/MainPage.cpp +++ b/retroshare-gui/src/gui/MainPage.cpp @@ -18,12 +18,14 @@ * * *******************************************************************************/ -#include -#include - #include + #include "common/FloatingHelpBrowser.h" #include "gui/settings/rsharesettings.h" +#include "util/misc.h" + +#include +#include MainPage::MainPage(QWidget *parent , Qt::WindowFlags flags ) : QWidget(parent, flags) { @@ -44,13 +46,13 @@ UserNotify *MainPage::getUserNotify() void MainPage::registerHelpButton(QToolButton *button, const QString& help_html_text, const QString &code_name) { - mHelpCodeName = code_name ; + mHelpCodeName = code_name ; - if (mHelpBrowser == NULL) + if (mHelpBrowser == nullptr) mHelpBrowser = new FloatingHelpBrowser(this, button) ; - float S = QFontMetricsF(button->font()).height() ; - button->setIconSize(QSize(S,S)) ; + int H = misc::getFontSizeFactor("HelpButton").height(); + button->setIconSize(QSize(H, H)) ;//Square Icon mHelpBrowser->setHelpText(help_html_text) ; } diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index d86ba2d7a..252560d43 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -32,6 +32,7 @@ #include #include +#include "util/misc.h" #include "util/qtthreadsutils.h" #include "feeds/BoardsCommentsItem.h" #include "feeds/ChatMsgItem.h" @@ -111,22 +112,23 @@ NewsFeed::NewsFeed(QWidget *parent) : MainPage(parent), ui(new Ui::NewsFeed), connect(ui->feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions())); ui->feedOptionsButton->hide(); // (csoler) Hidden until we repare the system to display a specific settings page. -QString hlp_str = tr( - "

  Activity Feed

\ -

The Activity Feed displays the last events on your network, sorted by the time you received them. \ - This gives you a summary of the activity of your friends. \ - You can configure which events to show by pressing on Options.

\ -

The various events shown are: \ -

    \ -
  • Connection attempts (useful to make friends with new people and control who's trying to reach you)
  • \ -
  • Channel, Forum and Board posts
  • \ -
  • Circle membership requests and invites
  • \ -
  • New Channels, Forums and Boards you can subscribe to
  • \ -
  • Channel and Board comments
  • \ -
  • New Mail messages
  • \ -
  • Private messages from your friends
  • \ -

\ - ") ; + int H = misc::getFontSizeFactor("HelpButton").height(); + QString hlp_str = tr( + "

  Activity Feed

" + "

The Activity Feed displays the last events on your network, sorted by the time you received them." + " This gives you a summary of the activity of your friends." + " You can configure which events to show by pressing on Options.

" + "

The various events shown are:" + "

    " + "
  • Connection attempts (useful to make friends with new people and control who's trying to reach you)
  • " + "
  • Channel, Forum and Board posts
  • " + "
  • Circle membership requests and invites
  • " + "
  • New Channels, Forums and Boards you can subscribe to
  • " + "
  • Channel and Board comments
  • " + "
  • New Mail messages
  • " + "
  • Private messages from your friends
  • " + "

" + ).arg(QString::number(2*H)); registerHelpButton(ui->helpButton,hlp_str,"NewFeed") ; diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp index f1837da3b..33a9c5854 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -26,6 +26,7 @@ #include "gui/gxs/GxsGroupShareKey.h" #include "gui/settings/rsharesettings.h" #include "gui/common/GroupTreeWidget.h" +#include "util/misc.h" #include "util/qtthreadsutils.h" #include @@ -95,14 +96,19 @@ UserNotify *PostedDialog::createUserNotify(QObject *parent) QString PostedDialog::getHelpString() const { - QString hlp_str = tr("

  Boards

\ -

The Boards service allows you to share images, blog posts & internet links, that spread among Retroshare nodes like forums and \ - channels

\ -

Posts can be commented by subscribed users. A promotion system also gives the opportunity to \ - enlight important links.

\ -

There is no restriction on which links are shared. Be careful when clicking on them.

\ -

Boards are kept for %1 days, and sync-ed over the last %2 days, unless you change this.

\ - ").arg(QString::number(rsPosted->getDefaultStoragePeriod()/86400)).arg(QString::number(rsPosted->getDefaultSyncPeriod()/86400)); + int H = misc::getFontSizeFactor("HelpButton").height(); + + QString hlp_str = tr( + "

  Boards

" + "

The Boards service allows you to share images, blog posts & internet links, that spread among Retroshare nodes like forums and" + " channels

" + "

Posts can be commented by subscribed users. A promotion system also gives the opportunity to" + " enlight important links.

" + "

There is no restriction on which links are shared. Be careful when clicking on them.

" + "

Boards are kept for %2 days, and sync-ed over the last %3 days, unless you change this.

" + ).arg( QString::number(2*H) + , QString::number(rsPosted->getDefaultStoragePeriod()/86400) + , QString::number(rsPosted->getDefaultSyncPeriod()/86400)); return hlp_str ; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index 5c6d1ae31..1abed7c64 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -35,6 +35,7 @@ #include "gui/notifyqt.h" #include "gui/common/GroupTreeWidget.h" #include "util/qtthreadsutils.h" +#include "util/misc.h" // class GxsChannelGroupInfoData : public RsUserdata // { @@ -90,8 +91,8 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr ev const RsGxsChannelSearchResultEvent*f = dynamic_cast(event.get()); - if(nullptr != f) - for(auto it:f->mSearchResultsMap) + if(nullptr != f) + for(auto &it:f->mSearchResultsMap) updateSearchResults(it.first); } @@ -102,18 +103,23 @@ GxsChannelDialog::~GxsChannelDialog() QString GxsChannelDialog::getHelpString() const { - QString hlp_str = tr("

  Channels

\ -

Channels allow you to post data (e.g. movies, music) that will spread in the network

\ -

You can see the channels your friends are subscribed to, and you automatically forward subscribed channels to \ - your friends. This promotes good channels in the network.

\ -

Only the channel's creator can post on that channel. Other peers \ - in the network can only read from it, unless the channel is private. You can however share \ - the posting rights or the reading rights with friend Retroshare nodes.

\ -

Channels can be made anonymous, or attached to a Retroshare identity so that readers can contact you if needed.\ - Enable \"Allow Comments\" if you want to let users comment on your posts.

\ -

Channel posts are kept for %1 days, and sync-ed over the last %2 days, unless you change this.

\ -

UI Tip: use Control + mouse wheel to control image size in the thumbnail view.

\ - ").arg(QString::number(rsGxsChannels->getDefaultStoragePeriod()/86400)).arg(QString::number(rsGxsChannels->getDefaultSyncPeriod()/86400)); + int H = misc::getFontSizeFactor("HelpButton").height(); + + QString hlp_str = tr( + "

  Channels

" + "

Channels allow you to post data (e.g. movies, music) that will spread in the network

" + "

You can see the channels your friends are subscribed to, and you automatically forward subscribed channels to" + " your friends. This promotes good channels in the network.

" + "

Only the channel's creator can post on that channel. Other peers" + " in the network can only read from it, unless the channel is private. You can however share" + " the posting rights or the reading rights with friend Retroshare nodes.

" + "

Channels can be made anonymous, or attached to a Retroshare identity so that readers can contact you if needed." + " Enable \"Allow Comments\" if you want to let users comment on your posts.

" + "

Channel posts are kept for %2 days, and sync-ed over the last %3 days, unless you change this.

" + "

UI Tip: use Control + mouse wheel to control image size in the thumbnail view.

" + ).arg( QString::number(2*H) + , QString::number(rsGxsChannels->getDefaultStoragePeriod()/86400) + , QString::number(rsGxsChannels->getDefaultSyncPeriod()/86400)); return hlp_str ; } @@ -260,11 +266,13 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF if (isSubscribed) { - QAction *action = autoDownload ? (new QAction(FilesDefs::getIconFromQtResourcePath(":/images/redled.png"), tr("Disable Auto-Download"), this)) - : (new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),tr("Enable Auto-Download"), this)); + { + QAction *action = autoDownload ? (new QAction(FilesDefs::getIconFromQtResourcePath(":/images/redled.png"), tr("Disable Auto-Download"), this)) + : (new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),tr("Enable Auto-Download"), this)); - connect(action, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); - actions.append(action); + connect(action, SIGNAL(triggered()), this, SLOT(toggleAutoDownload())); + actions.append(action); + } std::string dl_directory; rsGxsChannels->getChannelDownloadDirectory(grpId,dl_directory) ; @@ -282,20 +290,20 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF for(std::list::const_iterator it(lst.begin());it!=lst.end();++it) { - QAction *action = NULL; + QAction *fileAction = NULL; if(dl_directory == it->filename) { - action = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),QString::fromUtf8(it->filename.c_str()),NULL) ; + fileAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),QString::fromUtf8(it->filename.c_str()),NULL) ; found = true ; } else - action = new QAction(QString::fromUtf8(it->filename.c_str()),NULL) ; + fileAction = new QAction(QString::fromUtf8(it->filename.c_str()),NULL) ; - connect(action,SIGNAL(triggered()),this,SLOT(setDownloadDirectory())) ; - action->setData(QString::fromUtf8(it->filename.c_str())) ; + connect(fileAction,SIGNAL(triggered()),this,SLOT(setDownloadDirectory())) ; + fileAction->setData(QString::fromUtf8(it->filename.c_str())) ; - mnu->addAction(action) ; + mnu->addAction(fileAction) ; } if(!found && !dl_directory.empty()) @@ -368,17 +376,17 @@ bool GxsChannelDialog::getGroupData(std::list& groupInfo { std::vector groups; - // request all group infos at once + // request all group infos at once - if(! rsGxsChannels->getChannelsInfo(std::list(),groups)) - return false; + if(! rsGxsChannels->getChannelsInfo(std::list(),groups)) + return false; - /* Save groups to fill icons and description */ + /* Save groups to fill icons and description */ for (auto& group: groups) - groupInfo.push_back(new RsGxsChannelGroup(group)); + groupInfo.push_back(new RsGxsChannelGroup(group)); - return true; + return true; } void GxsChannelDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 9527d8675..367935382 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -24,9 +24,10 @@ #include "CreateGxsForumMsg.h" #include "GxsForumUserNotify.h" #include "gui/notifyqt.h" -#include "gui/gxs/GxsGroupShareKey.h" -#include "util/qtthreadsutils.h" #include "gui/common/GroupTreeWidget.h" +#include "gui/gxs/GxsGroupShareKey.h" +#include "util/misc.h" +#include "util/qtthreadsutils.h" class GxsForumGroupInfoData : public RsUserdata { @@ -110,13 +111,17 @@ bool GxsForumsDialog::getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupSta QString GxsForumsDialog::getHelpString() const { + int H = misc::getFontSizeFactor("HelpButton").height(); + QString hlp_str = tr( - "

  Forums

\ -

Retroshare Forums look like internet forums, but they work in a decentralized way

\ -

You see forums your friends are subscribed to, and you forward subscribed forums to \ - your friends. This automatically promotes interesting forums in the network.

\ -

Forum messages are kept for %1 days and sync-ed over the last %2 days, unless you configure it otherwise.

\ - ").arg(QString::number(rsGxsForums->getDefaultStoragePeriod()/86400)).arg(QString::number(rsGxsForums->getDefaultSyncPeriod()/86400)); + "

  Forums

" + "

Retroshare Forums look like internet forums, but they work in a decentralized way

" + "

You see forums your friends are subscribed to, and you forward subscribed forums to" + " your friends. This automatically promotes interesting forums in the network.

" + "

Forum messages are kept for %2 days and sync-ed over the last %3 days, unless you configure it otherwise.

" + ).arg( QString::number(2*H) + , QString::number(rsGxsForums->getDefaultStoragePeriod()/86400) + , QString::number(rsGxsForums->getDefaultSyncPeriod()/86400)); return hlp_str ; } @@ -233,9 +238,11 @@ void GxsForumsDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *grou groupItemInfo.description = QString::fromUtf8(forumGroupData->mDescription.c_str()); if (!groupData->mMeta.mCircleId.isNull() ) + { if (details.mRestrictedCircleId == details.mCircleId) groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/forums-red.png"); else groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/forums-signed.png"); + } } diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index c5c3c543c..d39baf6d5 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -44,9 +44,10 @@ #include "gui/settings/rsharesettings.h" #include "util/DateTime.h" -#include "util/RsProtectedTimer.h" +#include "util/misc.h" #include "util/QtVersion.h" #include "util/qtthreadsutils.h" +#include "util/RsProtectedTimer.h" #include #include @@ -254,17 +255,17 @@ MessagesDialog::MessagesDialog(QWidget *parent) ui.tabWidget->hideCloseButton(0); ui.tabWidget->setHideTabBarWithOneTab(true); - int S = QFontMetricsF(font()).height(); - QString help_str = tr( - "

  Messages

\ -

Retroshare has its own internal email system. You can send/receive emails to/from connected friend nodes.

\ -

It is also possible to send messages to other people's Identities using the global routing system. These messages \ - are always encrypted and signed, and are relayed by intermediate nodes until they reach their final destination.

\ -

Distant messages stay into your Outbox until an acknowledgement of receipt has been received.

\ -

Generally, you may use messages to recommend files to your friends by pasting file links, \ - or recommend friend nodes to other friend nodes, in order to strengthen your network, or send feedback \ - to a channel's owner.

\ - ").arg(QString::number(2*S), QString::number(S)) ; + int H = misc::getFontSizeFactor("HelpButton").height(); + QString help_str = tr( + "

  Messages

" + "

Retroshare has its own internal email system. You can send/receive emails to/from connected friend nodes.

" + "

It is also possible to send messages to other people's Identities using the global routing system. These messages" + " are always encrypted and signed, and are relayed by intermediate nodes until they reach their final destination.

" + "

Distant messages stay into your Outbox until an acknowledgement of receipt has been received.

" + "

Generally, you may use messages to recommend files to your friends by pasting file links," + " or recommend friend nodes to other friend nodes, in order to strengthen your network, or send feedback" + " to a channel's owner.

" + ).arg(QString::number(2*H)) ; registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ; diff --git a/retroshare-gui/src/util/misc.cpp b/retroshare-gui/src/util/misc.cpp index e63ad2fd6..c24ea2d11 100644 --- a/retroshare-gui/src/util/misc.cpp +++ b/retroshare-gui/src/util/misc.cpp @@ -19,17 +19,20 @@ * * *******************************************************************************/ -#include +#include "misc.h" + +#include "gui/common/FilesDefs.h" +#include "util/rsdebug.h" + +#include +#include +#include #include #include -#include -#include -#include #include +#include -#include "misc.h" -#include "util/rsdebug.h" -#include "gui/common/FilesDefs.h" +#include // return best userfriendly storage unit (B, KiB, MiB, GiB, TiB) // use Binary prefix standards from IEC 60027-2 @@ -67,46 +70,44 @@ QString misc::fingerPrintStyleSplit(const QString& in) bool misc::isPreviewable(QString extension) { extension = extension.toUpper(); - if(extension == "AVI") return true; - if(extension == "MP3") return true; - if(extension == "OGG") return true; - if(extension == "OGM") return true; - if(extension == "WMV") return true; - if(extension == "WMA") return true; - if(extension == "MPEG") return true; - if(extension == "MPG") return true; - if(extension == "ASF") return true; - if(extension == "QT") return true; - if(extension == "RM") return true; - if(extension == "RMVB") return true; - if(extension == "RMV") return true; - if(extension == "SWF") return true; - if(extension == "FLV") return true; - if(extension == "WAV") return true; - if(extension == "MOV") return true; - if(extension == "VOB") return true; - if(extension == "MID") return true; - if(extension == "AC3") return true; - if(extension == "MP4") return true; - if(extension == "MP2") return true; - if(extension == "AVI") return true; - if(extension == "FLAC") return true; - if(extension == "AU") return true; - if(extension == "MPE") return true; - if(extension == "MOV") return true; - if(extension == "MKV") return true; - if(extension == "AIF") return true; - if(extension == "AIFF") return true; - if(extension == "AIFC") return true; - if(extension == "RA") return true; - if(extension == "RAM") return true; - if(extension == "M4P") return true; - if(extension == "M4A") return true; if(extension == "3GP") return true; if(extension == "AAC") return true; - if(extension == "SWA") return true; + if(extension == "AC3") return true; + if(extension == "AIF") return true; + if(extension == "AIFC") return true; + if(extension == "AIFF") return true; + if(extension == "ASF") return true; + if(extension == "AU") return true; + if(extension == "AVI") return true; + if(extension == "FLAC") return true; + if(extension == "FLV") return true; + if(extension == "M4P") return true; + if(extension == "M4A") return true; + if(extension == "MOV") return true; + if(extension == "MID") return true; + if(extension == "MKV") return true; + if(extension == "MP2") return true; + if(extension == "MP3") return true; + if(extension == "MP4") return true; if(extension == "MPC") return true; + if(extension == "MPE") return true; + if(extension == "MPEG") return true; + if(extension == "MPG") return true; if(extension == "MPP") return true; + if(extension == "OGG") return true; + if(extension == "OGM") return true; + if(extension == "QT") return true; + if(extension == "RA") return true; + if(extension == "RAM") return true; + if(extension == "RM") return true; + if(extension == "RMV") return true; + if(extension == "RMVB") return true; + if(extension == "SWA") return true; + if(extension == "SWF") return true; + if(extension == "VOB") return true; + if(extension == "WAV") return true; + if(extension == "WMA") return true; + if(extension == "WMV") return true; return false; } @@ -227,8 +228,6 @@ QString misc::userFriendlyUnit(double count, unsigned int decimal, double factor return "0"; } - QString output; - int i; for (i = 0; i < 5; ++i) { if (count < factor) { @@ -434,3 +433,12 @@ void misc::clearLayout(QLayout * layout) { //delete item;//Auto deleted by Qt. } } + +QSizeF misc::getFontSizeFactor(const QString &group, const qreal defaultFactor /*= 1.0*/) +{ + static qreal appFontWidth = QFontMetrics(QApplication::font()).maxWidth(); + static qreal appFontHeight = QFontMetrics(QApplication::font()).height(); + qreal factor = Settings->valueFromGroup("FontHeighFactor",group,defaultFactor).toReal(); + return QSizeF(appFontWidth*factor,appFontHeight*factor); +} + diff --git a/retroshare-gui/src/util/misc.h b/retroshare-gui/src/util/misc.h index f09280ecf..2863a867c 100644 --- a/retroshare-gui/src/util/misc.h +++ b/retroshare-gui/src/util/misc.h @@ -22,14 +22,15 @@ #ifndef MISC_H #define MISC_H -#include +#include "gui/settings/rsharesettings.h" + +#include +#include #include #include #include -#include -#include -#include "gui/settings/rsharesettings.h" +#include /* Miscellaneaous functions that can be useful */ class misc : public QObject @@ -165,15 +166,15 @@ class misc : public QObject static QPixmap getOpenThumbnailedPicture(QWidget *parent, const QString &caption, int width, int height); static bool getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type , const QString &caption, const QString &filter - , QString &file, QFileDialog::Options options = 0); + , QString &file, QFileDialog::Options options = QFileDialog::Options()); static bool getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type , const QString &caption, const QString &filter - , QStringList &files, QFileDialog::Options options = 0); + , QStringList &files, QFileDialog::Options options = QFileDialog::Options()); static bool getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type , const QString &caption , const QString &filter - , QString &file, QString *selectedFilter = NULL - , QFileDialog::Options options = 0); + , QString &file, QString *selectedFilter = NULL + , QFileDialog::Options options = QFileDialog::Options()); static QFont getFont(bool *ok , const QFont &initial @@ -187,6 +188,9 @@ class misc : public QObject //Clear QLayout static void clearLayout(QLayout *layout); + static QSizeF getFontSizeFactor(const QString &group, const qreal defaultFactor = 1.0); + static QSizeF getFontSizeFactor() {return getFontSizeFactor("Main");} + }; // Trick to get a portable sleep() function @@ -201,7 +205,7 @@ class SleeperThread : public QThread{ template class SignalsBlocker { public: - SignalsBlocker(T *blocked) : blocked(blocked), previous(blocked->blockSignals(true)) {} + explicit SignalsBlocker(T *blocked) : blocked(blocked), previous(blocked->blockSignals(true)) {} ~SignalsBlocker() { blocked->blockSignals(previous); } T *operator->() { return blocked; }