Merge pull request #2555 from PhenomRetroShare/Add_GeneralFontSizeFactor

Add General Font Size Factor
This commit is contained in:
csoler 2022-01-23 14:32:36 +01:00 committed by GitHub
commit 79d1575f71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 345 additions and 310 deletions

View File

@ -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("\
<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Chat Rooms</h1> \
<p>Chat rooms work pretty much like IRC. \
They allow you to talk anonymously with tons of people without the need to make friends.</p> \
<p>A chat room can be public (your friends see it) or private (your friends can't see it, unless you \
invite them with <img src=\":/icons/png/add.png\" width=%2/>). \
Once you have been invited to a private room, you will be able to see it when your friends \
are using it.</p> \
<p>The list at left shows \
chat lobbies your friends are participating in. You can either \
<ul> \
<li>Right click to create a new chat room</li> \
<li>Double click a chat room to enter, chat, and show it to your friends</li> \
</ul> \
Note: For the chat rooms to work properly, your computer needs be on time. So check your system clock!\
</p> \
"
).arg(QString::number(4*W), QString::number(2*W)) ;
int hbH = misc::getFontSizeFactor("HelpButton").height();
QString help_str = tr(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Chat Rooms</h1>"
"<p>Chat rooms work pretty much like IRC."
" They allow you to talk anonymously with tons of people without the need to make friends.</p>"
"<p>A chat room can be public (your friends see it) or private (your friends can't see it, unless you"
" invite them with <img src=\":/icons/png/add.png\" width=%2/>)."
" Once you have been invited to a private room, you will be able to see it when your friends"
" are using it.</p>"
"<p>The list at left shows"
" chat lobbies your friends are participating in. You can either"
" <ul>"
" <li>Right click to create a new chat room</li>"
" <li>Double click a chat room to enter, chat, and show it to your friends</li>"
" </ul>"
" Note: For the chat rooms to work properly, your computer needs be on time. So check your system clock!"
"</p>"
).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<RsGxsId> own_identities ;
rsIdentity->getOwnIds(own_identities) ;
if (item && item->type() == TYPE_LOBBY)
{
std::list<RsGxsId> 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<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
{
RsIdentityDetails idd ;
rsIdentity->getIdDetails(*it,idd) ;
for(std::list<RsGxsId>::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;
}
}

View File

@ -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 *) ;

View File

@ -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<TransferInfo>::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<int>(QFontMetricsF(font()).height());
int H = misc::getFontSizeFactor("HelpButton").height();
QString help_str = tr(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;"
"File Transfer</h1>"
"<p>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)</p>"
"<p>You can share files using the "
"<img src=\":/images/directoryadd_24x24_shadow.png\" width=%2 />"
" 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</p>"
"<p>The search tab reports files from your friends' file lists,"
" and distant files that can be reached anonymously using the "
"multi-hop tunnelling system.</p>")
.arg(QString::number(2*S)).arg(QString::number(S)) ;
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;"
" File Transfer</h1>"
"<p>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)</p>"
"<p>You can share files using the "
" <img src=\":/images/directoryadd_24x24_shadow.png\" width=%2 />"
" 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</p>"
"<p>The search tab reports files from your friends' file lists,"
" and distant files that can be reached anonymously using the "
" multi-hop tunnelling system.</p>"
).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<QString> expanded_hashes ;
std::set<QString> 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<RetroShareLink>::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<RetroShareLink>::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<RsFileHash> *ids, std::set<int
int i, imax = selectedRows.count();
for (i = 0; i < imax; ++i) {
QModelIndex index = selectedRows.at(i);
if (index.parent().isValid())
if (index.parent().isValid() && index.model())
index = index.model()->index(index.parent().row(), COLUMN_ID);
if (ids) {

View File

@ -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(
" <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Network</h1> \
<p>The Network tab shows your friend Retroshare nodes: the neighbor Retroshare nodes that are connected to you. \
</p> \
<p>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.</p> \
<p>On the right, you will find 3 useful tabs: \
<ul> \
<li>Broadcast sends messages to all connected nodes at once</li> \
<li>Local network graph shows the network around you, based on discovery information</li> \
<li>Keyring contains node keys you collected, mostly forwarded to you by your friend nodes</li> \
</ul> </p> \
") ;
int H = misc::getFontSizeFactor("HelpButton").height();
QString hlp_str = tr(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Network</h1>"
"<p>The Network tab shows your friend Retroshare nodes: the neighbor Retroshare nodes that are connected to you.</p>"
"<p>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.</p>"
"<p>On the right, you will find 3 useful tabs:"
" <ul>"
" <li>Broadcast sends messages to all connected nodes at once</li>"
" <li>Local network graph shows the network around you, based on discovery information</li>"
" <li>Keyring contains node keys you collected, mostly forwarded to you by your friend nodes</li>"
" </ul> </p>"
).arg(QString::number(2*H));
registerHelpButton(ui.helpButton, hlp_str,"FriendsDialog") ;
registerHelpButton(ui.helpButton, hlp_str,"FriendsDialog") ;
}
FriendsDialog::~FriendsDialog ()

View File

@ -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(
" <h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Welcome to Retroshare!</h1>\
<p>You need to <b>make friends</b>! After you create a network of friends or join an existing network,\
you'll be able to exchange files, chat, talk in forums, etc. </p>\
<div align=center>\
<IMG align=\"center\" width=\"%2\" src=\":/images/network_map.png\"/> \
</div>\
<p>To do so, copy your Retroshare ID on this page and send it to friends, and add your friends' Retroshare ID.</p> \
<p>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.</p> ").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(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Welcome to Retroshare!</h1>"
"<p>You need to <b>make friends</b>! After you create a network of friends or join an existing network,"
" you'll be able to exchange files, chat, talk in forums, etc. </p>"
"<div align=\"center\"><IMG width=\"%2\" height=\"%3\" src=\":/images/network_map.png\" style=\"display: block; margin-left: auto; margin-right: auto; \"/></div>"
"<p>To do so, copy your Retroshare ID on this page and send it to friends, and add your friends' Retroshare ID.</p>"
"<p>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.</p>"
).arg(QString::number(2*H), QString::number(width()*0.5), QString::number(width()*0.5*(337.0/800.0)));//<img> 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<const RsEvent> 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);

View File

@ -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(
" <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Identities</h1> \
<p>In this tab you can create/edit <b>pseudo-anonymous identities</b>, and <b>circles</b>.</p> \
<p><b>Identities</b> 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.</p> \
<p>Identities can optionally be <b>signed</b> by your Retroshare node's certificate. \
Signed identities are easier to trust but are easily linked to your node's IP address.</p> \
<p><b>Anonymous identities</b> allow you to anonymously interact with other users. They cannot be \
spoofed, but noone can prove who really owns a given identity.</p> \
<p><b>Circles</b> 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. </p> \
<p>An <b>circle</b> 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.</p>") ;
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Identities</h1>"
"<p>In this tab you can create/edit <b>pseudo-anonymous identities</b>, and <b>circles</b>.</p>"
"<p><b>Identities</b> 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.</p>"
"<p>Identities can optionally be <b>signed</b> by your Retroshare node's certificate."
" Signed identities are easier to trust but are easily linked to your node's IP address.</p>"
"<p><b>Anonymous identities</b> allow you to anonymously interact with other users. They cannot be"
" spoofed, but noone can prove who really owns a given identity.</p>"
"<p><b>Circles</b> 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. </p>"
"<p>An <b>circle</b> 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.</p>"
).arg(QString::number(2*H));
registerHelpButton(ui->helpButton, hlp_str,"PeopleDialog") ;

View File

@ -18,12 +18,14 @@
* *
*******************************************************************************/
#include <QToolButton>
#include <QTimer>
#include <retroshare-gui/mainpage.h>
#include "common/FloatingHelpBrowser.h"
#include "gui/settings/rsharesettings.h"
#include "util/misc.h"
#include <QToolButton>
#include <QTimer>
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) ;
}

View File

@ -32,6 +32,7 @@
#include <retroshare/rsplugin.h>
#include <retroshare/rsposted.h>
#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(
" <h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Activity Feed</h1> \
<p>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 <b>Options</b>. </p> \
<p>The various events shown are: \
<ul> \
<li>Connection attempts (useful to make friends with new people and control who's trying to reach you)</li> \
<li>Channel, Forum and Board posts</li> \
<li>Circle membership requests and invites</li> \
<li>New Channels, Forums and Boards you can subscribe to</li> \
<li>Channel and Board comments</li> \
<li>New Mail messages</li> \
<li>Private messages from your friends</li> \
</ul> </p> \
") ;
int H = misc::getFontSizeFactor("HelpButton").height();
QString hlp_str = tr(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Activity Feed</h1>"
"<p>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 <b>Options</b>. </p>"
"<p>The various events shown are:"
" <ul>"
" <li>Connection attempts (useful to make friends with new people and control who's trying to reach you)</li>"
" <li>Channel, Forum and Board posts</li>"
" <li>Circle membership requests and invites</li>"
" <li>New Channels, Forums and Boards you can subscribe to</li>"
" <li>Channel and Board comments</li>"
" <li>New Mail messages</li>"
" <li>Private messages from your friends</li>"
" </ul> </p>"
).arg(QString::number(2*H));
registerHelpButton(ui->helpButton,hlp_str,"NewFeed") ;

View File

@ -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 <retroshare/rsposted.h>
@ -95,14 +96,19 @@ UserNotify *PostedDialog::createUserNotify(QObject *parent)
QString PostedDialog::getHelpString() const
{
QString hlp_str = tr("<h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Boards</h1> \
<p>The Boards service allows you to share images, blog posts & internet links, that spread among Retroshare nodes like forums and \
channels</p> \
<p>Posts can be commented by subscribed users. A promotion system also gives the opportunity to \
enlight important links.</p> \
<p>There is no restriction on which links are shared. Be careful when clicking on them.</p>\
<p>Boards are kept for %1 days, and sync-ed over the last %2 days, unless you change this.</p>\
").arg(QString::number(rsPosted->getDefaultStoragePeriod()/86400)).arg(QString::number(rsPosted->getDefaultSyncPeriod()/86400));
int H = misc::getFontSizeFactor("HelpButton").height();
QString hlp_str = tr(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Boards</h1>"
"<p>The Boards service allows you to share images, blog posts & internet links, that spread among Retroshare nodes like forums and"
" channels</p>"
"<p>Posts can be commented by subscribed users. A promotion system also gives the opportunity to"
" enlight important links.</p>"
"<p>There is no restriction on which links are shared. Be careful when clicking on them.</p>"
"<p>Boards are kept for %2 days, and sync-ed over the last %3 days, unless you change this.</p>"
).arg( QString::number(2*H)
, QString::number(rsPosted->getDefaultStoragePeriod()/86400)
, QString::number(rsPosted->getDefaultSyncPeriod()/86400));
return hlp_str ;
}

View File

@ -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<const RsEvent> ev
const RsGxsChannelSearchResultEvent*f = dynamic_cast<const RsGxsChannelSearchResultEvent*>(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("<h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Channels</h1> \
<p>Channels allow you to post data (e.g. movies, music) that will spread in the network</p> \
<p>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.</p>\
<p>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.</p>\
<p>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.</p>\
<p>Channel posts are kept for %1 days, and sync-ed over the last %2 days, unless you change this.</p>\
<p>UI Tip: use Control + mouse wheel to control image size in the thumbnail view.</p>\
").arg(QString::number(rsGxsChannels->getDefaultStoragePeriod()/86400)).arg(QString::number(rsGxsChannels->getDefaultSyncPeriod()/86400));
int H = misc::getFontSizeFactor("HelpButton").height();
QString hlp_str = tr(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Channels</h1>"
"<p>Channels allow you to post data (e.g. movies, music) that will spread in the network</p>"
"<p>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.</p>"
"<p>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.</p>"
"<p>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.</p>"
"<p>Channel posts are kept for %2 days, and sync-ed over the last %3 days, unless you change this.</p>"
"<p>UI Tip: use Control + mouse wheel to control image size in the thumbnail view.</p>"
).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<SharedDirInfo>::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<RsGxsGenericGroupData*>& groupInfo
{
std::vector<RsGxsChannelGroup> groups;
// request all group infos at once
// request all group infos at once
if(! rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>(),groups))
return false;
if(! rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>(),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)

View File

@ -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(
"<h1><img width=\"32\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Forums</h1> \
<p>Retroshare Forums look like internet forums, but they work in a decentralized way</p> \
<p>You see forums your friends are subscribed to, and you forward subscribed forums to \
your friends. This automatically promotes interesting forums in the network.</p> \
<p>Forum messages are kept for %1 days and sync-ed over the last %2 days, unless you configure it otherwise.</p>\
").arg(QString::number(rsGxsForums->getDefaultStoragePeriod()/86400)).arg(QString::number(rsGxsForums->getDefaultSyncPeriod()/86400));
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Forums</h1>"
"<p>Retroshare Forums look like internet forums, but they work in a decentralized way</p>"
"<p>You see forums your friends are subscribed to, and you forward subscribed forums to"
" your friends. This automatically promotes interesting forums in the network.</p>"
"<p>Forum messages are kept for %2 days and sync-ed over the last %3 days, unless you configure it otherwise.</p>"
).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");
}
}

View File

@ -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 <retroshare/rspeers.h>
#include <retroshare/rsmsgs.h>
@ -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(
" <h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Messages</h1> \
<p>Retroshare has its own internal email system. You can send/receive emails to/from connected friend nodes.</p> \
<p>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. </p>\
<p>Distant messages stay into your Outbox until an acknowledgement of receipt has been received.</p>\
<p>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.</p> \
").arg(QString::number(2*S), QString::number(S)) ;
int H = misc::getFontSizeFactor("HelpButton").height();
QString help_str = tr(
"<h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Messages</h1>"
"<p>Retroshare has its own internal email system. You can send/receive emails to/from connected friend nodes.</p>"
"<p>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. </p>"
"<p>Distant messages stay into your Outbox until an acknowledgement of receipt has been received.</p>"
"<p>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.</p>"
).arg(QString::number(2*H)) ;
registerHelpButton(ui.helpButton,help_str,"MessagesDialog") ;

View File

@ -19,17 +19,20 @@
* *
*******************************************************************************/
#include <QString>
#include "misc.h"
#include "gui/common/FilesDefs.h"
#include "util/rsdebug.h"
#include <QApplication>
#include <QBuffer>
#include <QByteArray>
#include <QDir>
#include <QFileDialog>
#include <QByteArray>
#include <QBuffer>
#include <time.h>
#include <QFontDialog>
#include <QString>
#include "misc.h"
#include "util/rsdebug.h"
#include "gui/common/FilesDefs.h"
#include <time.h>
// 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);
}

View File

@ -22,14 +22,15 @@
#ifndef MISC_H
#define MISC_H
#include <stdexcept>
#include "gui/settings/rsharesettings.h"
#include <QFileDialog>
#include <QLayout>
#include <QObject>
#include <QPair>
#include <QThread>
#include <QFileDialog>
#include <QLayout>
#include "gui/settings/rsharesettings.h"
#include <stdexcept>
/* 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 T> 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; }