From 75695bf3669b8949b8f2f5835de8aa47f6ef2ecf Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 8 Aug 2020 00:24:44 +0200 Subject: [PATCH 01/21] Enabled Text markable & links clickable --- retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui index 550610748..27d128867 100644 --- a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui @@ -112,6 +112,12 @@ p, li { white-space: pre-wrap; } true + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + From 9ae790e80bd00b4a0cbe1675ee4e2271494c57ee Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Aug 2020 12:56:27 +0200 Subject: [PATCH 02/21] fixed memory leak due to QPainter::save() called twice but restore() called only once --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index cc60e003b..2a44ba985 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -102,7 +102,6 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & RsGxsChannelPost post = index.data(Qt::UserRole).value() ; - painter->save(); painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); From 98edbc55d2e30c9726234bff20e1a6bfcfb5b110 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Aug 2020 13:18:39 +0200 Subject: [PATCH 03/21] fixed memory leak in SharedFilesDialog where destructor was not freeing the tree models --- .../gui/FileTransfer/SharedFilesDialog.cpp | 1407 +++++++++-------- .../src/gui/FileTransfer/SharedFilesDialog.h | 4 +- 2 files changed, 708 insertions(+), 703 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 68978c8f2..90860ff2c 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -146,45 +146,50 @@ public: } }; +SharedFilesDialog::~SharedFilesDialog() +{ + delete tree_model; + delete flat_model; + delete tree_proxyModel; +} /** Constructor */ -SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareDirModel *_flat_model,QWidget *parent) +SharedFilesDialog::SharedFilesDialog(bool remote_mode, QWidget *parent) : RsAutoUpdatePage(1000,parent), model(NULL) { - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); - NotifyQt *notify = NotifyQt::getInstance(); - connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); - connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); + NotifyQt *notify = NotifyQt::getInstance(); + connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool))); + connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool))); - connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); + connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int))); + connect(ui.dirTreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( spawnCustomPopupMenu( QPoint ) ) ); + connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int))); - connect( ui.dirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( spawnCustomPopupMenu( QPoint ) ) ); + tree_model = new TreeStyle_RDM(remote_mode); + flat_model = new FlatStyle_RDM(remote_mode); - connect(ui.indicatorCBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indicatorChanged(int))); + connect(flat_model, SIGNAL(layoutChanged()), this, SLOT(updateDirTreeView()) ); - tree_model = _tree_model ; - flat_model = _flat_model ; - connect(flat_model, SIGNAL(layoutChanged()), this, SLOT(updateDirTreeView()) ); + // For filtering items we use a trick: the underlying model will use this FilterRole role to highlight selected items + // while the filterProxyModel will select them using the pre-chosen string "filtered". - // For filtering items we use a trick: the underlying model will use this FilterRole role to highlight selected items - // while the filterProxyModel will select them using the pre-chosen string "filtered". - - tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this); - tree_proxyModel->setSourceModel(tree_model); - tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - tree_proxyModel->setSortRole(RetroshareDirModel::SortRole); - tree_proxyModel->sort(COLUMN_NAME); - tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); - tree_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; + tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this); + tree_proxyModel->setSourceModel(tree_model); + tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + tree_proxyModel->setSortRole(RetroshareDirModel::SortRole); + tree_proxyModel->sort(COLUMN_NAME); + tree_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); + tree_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this); flat_proxyModel->setSourceModel(flat_model); flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); flat_proxyModel->setSortRole(RetroshareDirModel::SortRole); flat_proxyModel->sort(COLUMN_NAME); - flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); - flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; + flat_proxyModel->setFilterRole(RetroshareDirModel::FilterRole); + flat_proxyModel->setFilterRegExp(QRegExp(QString(RETROSHARE_DIR_MODEL_FILTER_STRING))) ; // Mr.Alice: I removed this because it causes a crash for some obscur reason. Apparently when the model is changed, the proxy model cannot // deal with the change by itself. Should I call something specific? I've no idea. Removing this does not seem to cause any harm either. @@ -193,31 +198,31 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD flat_proxyModel->setDynamicSortFilter(false); connect(ui.filterClearButton, SIGNAL(clicked()), this, SLOT(clearFilter())); - connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); - connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter())); - connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onFilterTextEdited())); - //Hidden by default, shown on onFilterTextEdited - ui.filterClearButton->hide(); - ui.filterStartButton->hide(); + connect(ui.filterStartButton, SIGNAL(clicked()), this, SLOT(startFilter())); + connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter())); + connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(onFilterTextEdited())); + //Hidden by default, shown on onFilterTextEdited + ui.filterClearButton->hide(); + ui.filterStartButton->hide(); // mFilterTimer = new RsProtectedTimer( this ); // mFilterTimer->setSingleShot( true ); // Ensure the timer will fire only once after it was started // connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(filterRegExpChanged())); - /* Set header resize modes and initial section sizes */ - QHeaderView * header = ui.dirTreeView->header () ; + /* Set header resize modes and initial section sizes */ + QHeaderView * header = ui.dirTreeView->header () ; - header->resizeSection ( COLUMN_NAME, 490 ); - header->resizeSection ( COLUMN_FILENB, 70 ); - header->resizeSection ( COLUMN_SIZE, 70 ); - header->resizeSection ( COLUMN_AGE, 100 ); - header->resizeSection ( COLUMN_FRIEND_ACCESS,100); - header->resizeSection ( COLUMN_WN_VISU_DIR, 100 ); + header->resizeSection ( COLUMN_NAME, 490 ); + header->resizeSection ( COLUMN_FILENB, 70 ); + header->resizeSection ( COLUMN_SIZE, 70 ); + header->resizeSection ( COLUMN_AGE, 100 ); + header->resizeSection ( COLUMN_FRIEND_ACCESS,100); + header->resizeSection ( COLUMN_WN_VISU_DIR, 100 ); - header->setStretchLastSection(false); + header->setStretchLastSection(false); - /* Set Multi Selection */ - ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); + /* Set Multi Selection */ + ui.dirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); /* Hide platform specific features */ copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Links to Clipboard" ), this ); @@ -230,36 +235,36 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD removeExtraFileAct = new QAction(QIcon(), tr( "Stop sharing this file" ), this ); connect( removeExtraFileAct , SIGNAL( triggered() ), this, SLOT( removeExtraFile() ) ); - collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ; - connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ; - collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ; - connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif())) ; - collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this) ; - connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())) ; - collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ) ; - connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())) ; + collCreateAct= new QAction(QIcon(IMAGE_COLLCREATE), tr("Create Collection..."), this) ; + connect(collCreateAct,SIGNAL(triggered()),this,SLOT(collCreate())) ; + collModifAct= new QAction(QIcon(IMAGE_COLLMODIF), tr("Modify Collection..."), this) ; + connect(collModifAct,SIGNAL(triggered()),this,SLOT(collModif())) ; + collViewAct= new QAction(QIcon(IMAGE_COLLVIEW), tr("View Collection..."), this) ; + connect(collViewAct,SIGNAL(triggered()),this,SLOT(collView())) ; + collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this ) ; + connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen())) ; } LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent) - : SharedFilesDialog(new TreeStyle_RDM(false),new FlatStyle_RDM(false),parent) + : SharedFilesDialog(false,parent) { - // Hide columns after loading the settings - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; - ui.downloadButton->hide() ; + // Hide columns after loading the settings + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + ui.downloadButton->hide() ; - // load settings - processSettings(true); - // Setup the current view model. - // - changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; + // load settings + processSettings(true); + // Setup the current view model. + // + changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; - connect(ui.addShares_PB, SIGNAL(clicked()), this, SLOT(addShares())) ; - connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck())) ; + connect(ui.addShares_PB, SIGNAL(clicked()), this, SLOT(addShares())) ; + connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck())) ; - openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this) ; - connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile())) ; - openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this) ; - connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder())) ; + openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this) ; + connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile())) ; + openfolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this) ; + connect(openfolderAct, SIGNAL(triggered()), this, SLOT(openfolder())) ; ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES)) ; @@ -267,46 +272,46 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent) } RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent) - : SharedFilesDialog(new TreeStyle_RDM(true),new FlatStyle_RDM(true),parent) + : SharedFilesDialog(true,parent) { - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; - ui.checkButton->hide() ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; + ui.checkButton->hide() ; - connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected())); + connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected())); connect(ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), this, SLOT( expanded(const QModelIndex & ) ) ); connect(ui.dirTreeView, SIGNAL( doubleClicked(const QModelIndex & ) ), this, SLOT( expanded(const QModelIndex & ) ) ); - // load settings - processSettings(true); - // Setup the current view model. - // - changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; + // load settings + processSettings(true); + // Setup the current view model. + // + changeCurrentViewModel(ui.viewType_CB->currentIndex()) ; - ui.addShares_PB->hide() ; + ui.addShares_PB->hide() ; } void LocalSharedFilesDialog::addShares() { - ShareManager::showYourself(); + ShareManager::showYourself(); } void SharedFilesDialog::hideEvent(QHideEvent *) { - if(model!=NULL) - model->setVisible(false) ; + if(model!=NULL) + model->setVisible(false) ; } void SharedFilesDialog::showEvent(QShowEvent *) { - if(model!=NULL) - { + if(model!=NULL) + { std::set expanded_indexes,hidden_indexes,selected_indexes ; saveExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); - model->setVisible(true) ; - model->update() ; + model->setVisible(true) ; + model->update() ; restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); } @@ -325,63 +330,63 @@ LocalSharedFilesDialog::~LocalSharedFilesDialog() void LocalSharedFilesDialog::processSettings(bool bLoad) { - Settings->beginGroup("LocalSharedFilesDialog"); + Settings->beginGroup("LocalSharedFilesDialog"); - if (bLoad) { - // load settings + if (bLoad) { + // load settings - // state of the trees - ui.dirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray()); + // state of the trees + ui.dirTreeView->header()->restoreState(Settings->value("LocalDirTreeView").toByteArray()); - // state of splitter - ui.splitter->restoreState(Settings->value("LocalSplitter").toByteArray()); + // state of splitter + ui.splitter->restoreState(Settings->value("LocalSplitter").toByteArray()); - // view type - ui.viewType_CB->setCurrentIndex(Settings->value("LocalViewType").toInt()); - } else { - // save settings + // view type + ui.viewType_CB->setCurrentIndex(Settings->value("LocalViewType").toInt()); + } else { + // save settings - // state of trees - Settings->setValue("LocalDirTreeView", ui.dirTreeView->header()->saveState()); + // state of trees + Settings->setValue("LocalDirTreeView", ui.dirTreeView->header()->saveState()); - // state of splitter - Settings->setValue("LocalSplitter", ui.splitter->saveState()); + // state of splitter + Settings->setValue("LocalSplitter", ui.splitter->saveState()); - // view type - Settings->setValue("LocalViewType", ui.viewType_CB->currentIndex()); - } + // view type + Settings->setValue("LocalViewType", ui.viewType_CB->currentIndex()); + } - Settings->endGroup(); + Settings->endGroup(); } void RemoteSharedFilesDialog::processSettings(bool bLoad) { - Settings->beginGroup("RemoteSharedFilesDialog"); + Settings->beginGroup("RemoteSharedFilesDialog"); - if (bLoad) { - // load settings + if (bLoad) { + // load settings - // state of the trees - ui.dirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray()); + // state of the trees + ui.dirTreeView->header()->restoreState(Settings->value("RemoteDirTreeView").toByteArray()); - // state of splitter - ui.splitter->restoreState(Settings->value("RemoteSplitter").toByteArray()); + // state of splitter + ui.splitter->restoreState(Settings->value("RemoteSplitter").toByteArray()); - // view type - ui.viewType_CB->setCurrentIndex(Settings->value("RemoteViewType").toInt()); - } else { - // save settings + // view type + ui.viewType_CB->setCurrentIndex(Settings->value("RemoteViewType").toInt()); + } else { + // save settings - // state of trees - Settings->setValue("RemoteDirTreeView", ui.dirTreeView->header()->saveState()); + // state of trees + Settings->setValue("RemoteDirTreeView", ui.dirTreeView->header()->saveState()); - // state of splitter - Settings->setValue("RemoteSplitter", ui.splitter->saveState()); + // state of splitter + Settings->setValue("RemoteSplitter", ui.splitter->saveState()); - // view type - Settings->setValue("RemoteViewType", ui.viewType_CB->currentIndex()); - } + // view type + Settings->setValue("RemoteViewType", ui.viewType_CB->currentIndex()); + } - Settings->endGroup(); + Settings->endGroup(); } void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex) @@ -389,195 +394,195 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex) // disconnect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), NULL, NULL ); // disconnect( ui.dirTreeView, SIGNAL( expanded(const QModelIndex & ) ), NULL, NULL ); - if(model!=NULL) - model->setVisible(false) ; + if(model!=NULL) + model->setVisible(false) ; - if(viewTypeIndex==VIEW_TYPE_TREE) - { - model = tree_model ; + if(viewTypeIndex==VIEW_TYPE_TREE) + { + model = tree_model ; proxyModel = tree_proxyModel ; - } - else - { - model = flat_model ; + } + else + { + model = flat_model ; proxyModel = flat_proxyModel ; } - showProperColumns() ; + showProperColumns() ; std::set expanded_indexes,hidden_indexes,selected_indexes ; saveExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); if(isVisible()) - { + { model->setVisible(true) ; - model->update() ; - } + model->update() ; + } // connect( ui.dirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), this, SLOT( collapsed(const QModelIndex & ) ) ); - ui.dirTreeView->setModel(proxyModel); - ui.dirTreeView->update(); + ui.dirTreeView->setModel(proxyModel); + ui.dirTreeView->update(); restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes); QHeaderView * header = ui.dirTreeView->header () ; - QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive); + QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive); - ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ; + ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ; // recursRestoreExpandedItems(ui.dirTreeView->rootIndex(),expanded_indexes); - FilterItems(); + FilterItems(); } void LocalSharedFilesDialog::showProperColumns() { - if(model == tree_model) - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + if(model == tree_model) + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->hide(); - ui.filterPatternLineEdit->hide(); - ui.filterStartButton->hide(); - ui.filterClearButton->hide(); + ui.filterLabel->hide(); + ui.filterPatternLineEdit->hide(); + ui.filterStartButton->hide(); + ui.filterClearButton->hide(); #endif - } - else - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + } + else + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->show(); - ui.filterPatternLineEdit->show(); + ui.filterLabel->show(); + ui.filterPatternLineEdit->show(); #endif - } + } } void RemoteSharedFilesDialog::showProperColumns() { - if(model == tree_model) - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; + if(model == tree_model) + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->hide(); - ui.filterPatternLineEdit->hide(); - ui.filterStartButton->hide(); - ui.filterClearButton->hide(); + ui.filterLabel->hide(); + ui.filterPatternLineEdit->hide(); + ui.filterStartButton->hide(); + ui.filterClearButton->hide(); #endif - } - else - { - ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; - ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; - ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; + } + else + { + ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ; + ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ; + ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ; #ifdef DONT_USE_SEARCH_IN_TREE_VIEW - ui.filterLabel->show(); - ui.filterPatternLineEdit->show(); + ui.filterLabel->show(); + ui.filterPatternLineEdit->show(); #endif - } + } } void LocalSharedFilesDialog::checkUpdate() { - /* update */ - if (rsFiles->InDirectoryCheck()) - { - ui.checkButton->setText(tr("Checking...")); - } - else - { - ui.checkButton->setText(tr("Check files")); - ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE)); - ui.hashLabel->setToolTip("") ; - } + /* update */ + if (rsFiles->InDirectoryCheck()) + { + ui.checkButton->setText(tr("Checking...")); + } + else + { + ui.checkButton->setText(tr("Check files")); + ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_DONE)); + ui.hashLabel->setToolTip("") ; + } - return; + return; } void LocalSharedFilesDialog::forceCheck() { - rsFiles->ForceDirectoryCheck(); - return; + rsFiles->ForceDirectoryCheck(); + return; } void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) { - if (!rsPeers) return; /* not ready yet! */ + if (!rsPeers) return; /* not ready yet! */ - QMenu *contextMenu = new QMenu(this); + QMenu *contextMenu = new QMenu(this); - QModelIndex idx = ui.dirTreeView->indexAt(point) ; - if (idx.isValid()) - { + QModelIndex idx = ui.dirTreeView->indexAt(point) ; + if (idx.isValid()) + { - QModelIndex midx = proxyModel->mapToSource(idx) ; - if (midx.isValid()) - { + QModelIndex midx = proxyModel->mapToSource(idx) ; + if (midx.isValid()) + { - currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; - int type = model->getType(midx) ; - if ( (type == DIR_TYPE_DIR) || (type == DIR_TYPE_FILE) ) - { - collCreateAct->setEnabled(true); - collOpenAct->setEnabled(true); + currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; + int type = model->getType(midx) ; + if ( (type == DIR_TYPE_DIR) || (type == DIR_TYPE_FILE) ) + { + collCreateAct->setEnabled(true); + collOpenAct->setEnabled(true); - QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ; + QModelIndexList list = ui.dirTreeView->selectionModel()->selectedRows() ; - if(type == DIR_TYPE_DIR || list.size() > 1) - { - QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), contextMenu ) ; - connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ; - contextMenu->addAction( downloadActI) ; - } - else - { - QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), contextMenu ) ; - connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ; - contextMenu->addAction( downloadAct) ; - } + if(type == DIR_TYPE_DIR || list.size() > 1) + { + QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), contextMenu ) ; + connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ; + contextMenu->addAction( downloadActI) ; + } + else + { + QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), contextMenu ) ; + connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ; + contextMenu->addAction( downloadAct) ; + } - contextMenu->addSeparator() ;//------------------------------------ - contextMenu->addAction( copylinkAct) ; - contextMenu->addAction( sendlinkAct) ; - contextMenu->addSeparator() ;//------------------------------------ - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; + contextMenu->addSeparator() ;//------------------------------------ + contextMenu->addAction( copylinkAct) ; + contextMenu->addAction( sendlinkAct) ; + contextMenu->addSeparator() ;//------------------------------------ + contextMenu->addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; - contextMenu->addSeparator() ;//------------------------------------ + contextMenu->addSeparator() ;//------------------------------------ - QMenu collectionMenu(tr("Collection"), this); - collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); - collectionMenu.addAction(collCreateAct); - collectionMenu.addAction(collOpenAct); - contextMenu->addMenu(&collectionMenu) ; + QMenu collectionMenu(tr("Collection"), this); + collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); + collectionMenu.addAction(collCreateAct); + collectionMenu.addAction(collOpenAct); + contextMenu->addMenu(&collectionMenu) ; - } + } - } - } + } + } - contextMenu = model->getContextMenu(contextMenu); + contextMenu = model->getContextMenu(contextMenu); - if (!contextMenu->children().isEmpty()) - contextMenu->exec(QCursor::pos()) ; + if (!contextMenu->children().isEmpty()) + contextMenu->exec(QCursor::pos()) ; - delete contextMenu; + delete contextMenu; } QModelIndexList SharedFilesDialog::getSelected() { - QModelIndexList list = ui.dirTreeView->selectionModel()->selectedIndexes() ; - QModelIndexList proxyList ; - for (QModelIndexList::iterator index = list.begin(); index != list.end(); ++index ) { - proxyList.append(proxyModel->mapToSource(*index)) ; - } + QModelIndexList list = ui.dirTreeView->selectionModel()->selectedIndexes() ; + QModelIndexList proxyList ; + for (QModelIndexList::iterator index = list.begin(); index != list.end(); ++index ) { + proxyList.append(proxyModel->mapToSource(*index)) ; + } - return proxyList ; + return proxyList ; } void RemoteSharedFilesDialog::expanded(const QModelIndex& indx) @@ -590,69 +595,69 @@ void RemoteSharedFilesDialog::expanded(const QModelIndex& indx) } void RemoteSharedFilesDialog::downloadRemoteSelectedInteractive() { - /* call back to the model (which does all the interfacing? */ + /* call back to the model (which does all the interfacing? */ - std::cerr << "Downloading Files" ; - std::cerr << std::endl ; + std::cerr << "Downloading Files" ; + std::cerr << std::endl ; - QModelIndexList lst = getSelected() ; - model -> downloadSelected(lst,true) ; + QModelIndexList lst = getSelected() ; + model -> downloadSelected(lst,true) ; } void RemoteSharedFilesDialog::downloadRemoteSelected() { - /* call back to the model (which does all the interfacing? */ + /* call back to the model (which does all the interfacing? */ - std::cerr << "Downloading Files" ; - std::cerr << std::endl ; + std::cerr << "Downloading Files" ; + std::cerr << std::endl ; - QModelIndexList lst = getSelected() ; - model -> downloadSelected(lst,false) ; + QModelIndexList lst = getSelected() ; + model -> downloadSelected(lst,false) ; } void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList& urls,bool& has_unhashed_files) { - std::vector dirVec; + std::vector dirVec; - model->getDirDetailsFromSelect(lst, dirVec); + model->getDirDetailsFromSelect(lst, dirVec); - has_unhashed_files = false; + has_unhashed_files = false; - for (int i = 0, n = dirVec.size(); i < n; ++i) - { - const DirDetails& details = dirVec[i]; + for (int i = 0, n = dirVec.size(); i < n; ++i) + { + const DirDetails& details = dirVec[i]; - if (details.type == DIR_TYPE_DIR) - { - auto ft = RsFileTree::fromDirDetails(details,remote); + if (details.type == DIR_TYPE_DIR) + { + auto ft = RsFileTree::fromDirDetails(details,remote); - QString dir_name = QDir(QString::fromUtf8(details.name.c_str())).dirName(); + QString dir_name = QDir(QString::fromUtf8(details.name.c_str())).dirName(); - RetroShareLink link = RetroShareLink::createFileTree(dir_name,ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ; + RetroShareLink link = RetroShareLink::createFileTree(dir_name,ft->mTotalSize,ft->mTotalFiles,QString::fromStdString(ft->toRadix64())) ; - if(link.valid()) - urls.push_back(link) ; - } - else - { - if(details.hash.isNull()) - { - has_unhashed_files = true; - continue; - } - RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str()); - if (link.valid()) { - urls.push_back(link) ; - } - } - } + if(link.valid()) + urls.push_back(link) ; + } + else + { + if(details.hash.isNull()) + { + has_unhashed_files = true; + continue; + } + RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str()); + if (link.valid()) { + urls.push_back(link) ; + } + } + } } void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote) { - QList urls ; - bool has_unhashed_files = false; + QList urls ; + bool has_unhashed_files = false; - copyLinks(lst,remote,urls,has_unhashed_files) ; + copyLinks(lst,remote,urls,has_unhashed_files) ; RSLinkClipboard::copyLinks(urls) ; if(has_unhashed_files) @@ -699,108 +704,108 @@ void SharedFilesDialog::sendLinkTo() void SharedFilesDialog::collCreate() { - QModelIndexList lst = getSelected(); - model->createCollectionFile(this, lst); + QModelIndexList lst = getSelected(); + model->createCollectionFile(this, lst); } void SharedFilesDialog::collModif() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); - if(files_info.size() != 1) return ; + if(files_info.size() != 1) return ; - /* make path for downloaded files */ - std::list::iterator it = files_info.begin(); - DirDetails details = (*it); - FileInfo info; - if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL - | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE - | RS_FILE_HINTS_SPEC_ONLY, info)) return; + /* make path for downloaded files */ + std::list::iterator it = files_info.begin(); + DirDetails details = (*it); + FileInfo info; + if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL + | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE + | RS_FILE_HINTS_SPEC_ONLY, info)) return; - std::string path; - path = info.path; + std::string path; + path = info.path; - /* open file with a suitable application */ - QFileInfo qinfo; - qinfo.setFile(QString::fromUtf8(path.c_str())); - if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { - RsCollection collection; - collection.openColl(qinfo.absoluteFilePath()); - } - } + /* open file with a suitable application */ + QFileInfo qinfo; + qinfo.setFile(QString::fromUtf8(path.c_str())); + if (qinfo.exists()) { + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; + collection.openColl(qinfo.absoluteFilePath()); + } + } } void SharedFilesDialog::collView() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); - if(files_info.size() != 1) return ; + if(files_info.size() != 1) return ; - /* make path for downloaded files */ - std::list::iterator it = files_info.begin(); - DirDetails details = (*it); - FileInfo info; - if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL - | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE - | RS_FILE_HINTS_SPEC_ONLY, info)) return; + /* make path for downloaded files */ + std::list::iterator it = files_info.begin(); + DirDetails details = (*it); + FileInfo info; + if (!rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL + | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE + | RS_FILE_HINTS_SPEC_ONLY, info)) return; - std::string path; - path = info.path; + std::string path; + path = info.path; - /* open file with a suitable application */ - QFileInfo qinfo; - qinfo.setFile(QString::fromUtf8(path.c_str())); - if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { - RsCollection collection; - collection.openColl(qinfo.absoluteFilePath(), true); - } - } + /* open file with a suitable application */ + QFileInfo qinfo; + qinfo.setFile(QString::fromUtf8(path.c_str())); + if (qinfo.exists()) { + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; + collection.openColl(qinfo.absoluteFilePath(), true); + } + } } void SharedFilesDialog::collOpen() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); - if(files_info.size() == 1) { + if(files_info.size() == 1) { - /* make path for downloaded files */ - std::list::iterator it = files_info.begin(); - DirDetails details = (*it); - FileInfo info; - if (rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL - | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE - | RS_FILE_HINTS_SPEC_ONLY, info)) { + /* make path for downloaded files */ + std::list::iterator it = files_info.begin(); + DirDetails details = (*it); + FileInfo info; + if (rsFiles->FileDetails(details.hash, RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL + | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE + | RS_FILE_HINTS_SPEC_ONLY, info)) { - std::string path; - path = info.path; + std::string path; + path = info.path; - /* open file with a suitable application */ - QFileInfo qinfo; - qinfo.setFile(QString::fromUtf8(path.c_str())); - if (qinfo.exists()) { - if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { - RsCollection collection; - if (collection.load(qinfo.absoluteFilePath())) { - collection.downloadFiles(); - return; - } - } - } - } - } + /* open file with a suitable application */ + QFileInfo qinfo; + qinfo.setFile(QString::fromUtf8(path.c_str())); + if (qinfo.exists()) { + if (qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString)) { + RsCollection collection; + if (collection.load(qinfo.absoluteFilePath())) { + collection.downloadFiles(); + return; + } + } + } + } + } - RsCollection collection; - if (collection.load(this)) { - collection.downloadFiles(); - } + RsCollection collection; + if (collection.load(this)) { + collection.downloadFiles(); + } } void LocalSharedFilesDialog::playselectedfiles() @@ -817,12 +822,12 @@ void LocalSharedFilesDialog::playselectedfiles() QStringList fullpaths; for(it = paths.begin(); it != paths.end(); ++it) { - std::string fullpath; - rsFiles->ConvertSharedFilePath(*it, fullpath); - fullpaths.push_back(QString::fromStdString(fullpath)); + std::string fullpath; + rsFiles->ConvertSharedFilePath(*it, fullpath); + fullpaths.push_back(QString::fromStdString(fullpath)); - std::cerr << "Playing: " << fullpath; - std::cerr << std::endl; + std::cerr << "Playing: " << fullpath; + std::cerr << std::endl; } playFiles(fullpaths); @@ -857,27 +862,27 @@ void SharedFilesDialog::recommendFilesToMsg() void LocalSharedFilesDialog::openfile() { - /* call back to the model (which does all the interfacing? */ + /* call back to the model (which does all the interfacing? */ - std::cerr << "SharedFilesDialog::openfile" << std::endl; + std::cerr << "SharedFilesDialog::openfile" << std::endl; - QModelIndexList qmil = getSelected(); - model->openSelected(qmil); + QModelIndexList qmil = getSelected(); + model->openSelected(qmil); } void LocalSharedFilesDialog::openfolder() { - std::cerr << "SharedFilesDialog::openfolder" << std::endl; + std::cerr << "SharedFilesDialog::openfolder" << std::endl; - QModelIndexList qmil = getSelected(); - model->openSelected(qmil); + QModelIndexList qmil = getSelected(); + model->openSelected(qmil); } void SharedFilesDialog::preModDirectories(bool local) { - if (isRemote() == local) - return; + if (isRemote() == local) + return; #ifdef DEBUG_SHARED_FILES_DIALOG std::cerr << "About to modify directories. Local=" << local << ". Temporarily disabling sorting" << std::endl; @@ -888,9 +893,9 @@ void SharedFilesDialog::preModDirectories(bool local) std::set expanded_indexes,hidden_indexes,selected_indexes; saveExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; - /* Notify both models, only one is visible */ - tree_model->preMods(); - flat_model->preMods(); + /* Notify both models, only one is visible */ + tree_model->preMods(); + flat_model->preMods(); restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; } @@ -959,15 +964,15 @@ void SharedFilesDialog::expandAll() void SharedFilesDialog::recursExpandAll(const QModelIndex& index) { - ui.dirTreeView->setExpanded(index,true) ; + ui.dirTreeView->setExpanded(index,true) ; - for(int row=0;rowmodel()->rowCount(index);++row) - { - QModelIndex idx(index.child(row,0)) ; + for(int row=0;rowmodel()->rowCount(index);++row) + { + QModelIndex idx(index.child(row,0)) ; - if(ui.dirTreeView->model()->rowCount(idx) > 0) - recursExpandAll(idx) ; - } + if(ui.dirTreeView->model()->rowCount(idx) > 0) + recursExpandAll(idx) ; + } } void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const std::string& path, @@ -976,39 +981,39 @@ void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const s std::set& sel ) { - std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); + std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; + std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; #endif - if(ui.dirTreeView->selectionModel()->selection().contains(index)) - sel.insert(local_path) ; + if(ui.dirTreeView->selectionModel()->selection().contains(index)) + sel.insert(local_path) ; - // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 - /*if(ui.dirTreeView->isRowHidden(index.row(),index.parent())) - { - hid.insert(local_path) ; - return ; - }*/ + // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 + /*if(ui.dirTreeView->isRowHidden(index.row(),index.parent())) + { + hid.insert(local_path) ; + return ; + }*/ - if(ui.dirTreeView->isExpanded(index)) - { + if(ui.dirTreeView->isExpanded(index)) + { #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "Index " << local_path << " is expanded." << std::endl; + std::cerr << "Index " << local_path << " is expanded." << std::endl; #endif - if(index.isValid()) - exp.insert(local_path) ; + if(index.isValid()) + exp.insert(local_path) ; - for(int row=0;rowmodel()->rowCount(index);++row) + for(int row=0;rowmodel()->rowCount(index);++row) #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) - recursSaveExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; + recursSaveExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; #else - recursSaveExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; + recursSaveExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; #endif - } + } #ifdef DEBUG_SHARED_FILES_DIALOG - else - std::cerr << "Index is not expanded." << std::endl; + else + std::cerr << "Index is not expanded." << std::endl; #endif } @@ -1017,42 +1022,42 @@ void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, con const std::set& hid, const std::set &sel) { - std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); + std::string local_path = path+"/"+index.data(Qt::DisplayRole).toString().toStdString(); #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; + std::cerr << "at index " << index.row() << ". data[1]=" << local_path << std::endl; #endif - if(sel.find(local_path) != sel.end()) - ui.dirTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); + if(sel.find(local_path) != sel.end()) + ui.dirTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); - // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 - /*bool invisible = hid.find(local_path) != hid.end(); - ui.dirTreeView->setRowHidden(index.row(),index.parent(),invisible ) ;*/ + // Disable hidden check as we don't use it and Qt bug: https://bugreports.qt.io/browse/QTBUG-11438 + /*bool invisible = hid.find(local_path) != hid.end(); + ui.dirTreeView->setRowHidden(index.row(),index.parent(),invisible ) ;*/ - // if(invisible) - // mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + // if(invisible) + // mHiddenIndexes.push_back(proxyModel->mapToSource(index)); - if(/*!invisible &&*/ exp.find(local_path) != exp.end()) - { + if(/*!invisible &&*/ exp.find(local_path) != exp.end()) + { #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "re expanding index " << local_path << std::endl; + std::cerr << "re expanding index " << local_path << std::endl; #endif - ui.dirTreeView->setExpanded(index,true) ; + ui.dirTreeView->setExpanded(index,true) ; - for(int row=0;rowmodel()->rowCount(index);++row) + for(int row=0;rowmodel()->rowCount(index);++row) #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) - recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; + recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0,index),local_path,exp,hid,sel) ; #else - recursRestoreExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; + recursRestoreExpandedItems(index.child(row,0),local_path,exp,hid,sel) ; #endif - } + } } void SharedFilesDialog::postModDirectories(bool local) { - if (isRemote() == local) - return; + if (isRemote() == local) + return; std::set expanded_indexes,selected_indexes,hidden_indexes; @@ -1062,183 +1067,183 @@ void SharedFilesDialog::postModDirectories(bool local) #endif /* Notify both models, only one is visible */ - tree_model->postMods(); - flat_model->postMods(); - ui.dirTreeView->update() ; + tree_model->postMods(); + flat_model->postMods(); + ui.dirTreeView->update() ; - if (ui.filterPatternLineEdit->text().isEmpty() == false) - FilterItems(); + if (ui.filterPatternLineEdit->text().isEmpty() == false) + FilterItems(); - ui.dirTreeView->setSortingEnabled(true); + ui.dirTreeView->setSortingEnabled(true); - restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; + restoreExpandedPathsAndSelection(expanded_indexes,hidden_indexes,selected_indexes) ; #ifdef DEBUG_SHARED_FILES_DIALOG std::cerr << "****** updated directories! Re-enabling sorting ******" << std::endl; #endif - QCoreApplication::flush(); + QCoreApplication::flush(); } class ChannelCompare { public: - bool operator()(const std::pair& id1,const std::pair& id2) const - { - return id1.first < id2.first ; - } + bool operator()(const std::pair& id1,const std::pair& id2) const + { + return id1.first < id2.first ; + } }; void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) { - if (!rsPeers) return; /* not ready yet! */ + if (!rsPeers) return; /* not ready yet! */ - QModelIndex idx = ui.dirTreeView->indexAt(point) ; - if (!idx.isValid()) return ; + QModelIndex idx = ui.dirTreeView->indexAt(point) ; + if (!idx.isValid()) return ; - QModelIndex midx = proxyModel->mapToSource(idx) ; - if (!midx.isValid()) return ; + QModelIndex midx = proxyModel->mapToSource(idx) ; + if (!midx.isValid()) return ; - currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; - int type = model->getType(midx) ; - if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE && type != DIR_TYPE_EXTRA_FILE) return; + currentFile = model->data(midx, RetroshareDirModel::FileNameRole).toString() ; + int type = model->getType(midx) ; + if (type != DIR_TYPE_DIR && type != DIR_TYPE_FILE && type != DIR_TYPE_EXTRA_FILE) return; - QMenu contextMnu(this) ; + QMenu contextMnu(this) ; - bool bIsRsColl = currentFile.endsWith(RsCollection::ExtensionString); - collCreateAct->setEnabled(true); - collModifAct->setEnabled(bIsRsColl); - collViewAct->setEnabled(bIsRsColl); - collOpenAct->setEnabled(true); + bool bIsRsColl = currentFile.endsWith(RsCollection::ExtensionString); + collCreateAct->setEnabled(true); + collModifAct->setEnabled(bIsRsColl); + collViewAct->setEnabled(bIsRsColl); + collOpenAct->setEnabled(true); - QMenu collectionMenu(tr("Collection"), this); - collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); - collectionMenu.addAction(collCreateAct); - collectionMenu.addAction(collModifAct); - collectionMenu.addAction(collViewAct); - collectionMenu.addAction(collOpenAct); + QMenu collectionMenu(tr("Collection"), this); + collectionMenu.setIcon(QIcon(IMAGE_LIBRARY)); + collectionMenu.addAction(collCreateAct); + collectionMenu.addAction(collModifAct); + collectionMenu.addAction(collViewAct); + collectionMenu.addAction(collOpenAct); - switch (type) { - case DIR_TYPE_DIR : - contextMnu.addAction(openfolderAct) ; - contextMnu.addAction(copylinkAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addMenu(&collectionMenu) ; - break ; + switch (type) { + case DIR_TYPE_DIR : + contextMnu.addAction(openfolderAct) ; + contextMnu.addAction(copylinkAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addMenu(&collectionMenu) ; + break ; - case DIR_TYPE_FILE : - contextMnu.addAction(openfileAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addAction(copylinkAct) ; - contextMnu.addAction(sendlinkAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addMenu(&collectionMenu) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; + case DIR_TYPE_FILE : + contextMnu.addAction(openfileAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(copylinkAct) ; + contextMnu.addAction(sendlinkAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addMenu(&collectionMenu) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ; break; case DIR_TYPE_EXTRA_FILE: - contextMnu.addAction(openfileAct) ; - contextMnu.addSeparator() ;//------------------------------------ - contextMnu.addAction(copylinkAct) ; - contextMnu.addAction(sendlinkAct) ; - contextMnu.addAction(removeExtraFileAct) ; + contextMnu.addAction(openfileAct) ; + contextMnu.addSeparator() ;//------------------------------------ + contextMnu.addAction(copylinkAct) ; + contextMnu.addAction(sendlinkAct) ; + contextMnu.addAction(removeExtraFileAct) ; - break ; + break ; - default : - return ; - } + default : + return ; + } - QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards - QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards + QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards + QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards if(type != DIR_TYPE_EXTRA_FILE) - { - GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); + { + GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); - if(channelDialog != NULL) - { - shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL)); + if(channelDialog != NULL) + { + shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL)); - std::map grp_metas ; - channelDialog->getGroupList(grp_metas) ; + std::map grp_metas ; + channelDialog->getGroupList(grp_metas) ; - std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. + std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. - for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); + for(auto it(grp_metas.begin());it!=grp_metas.end();++it) + if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); - std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; + std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; - for(auto it(grplist.begin());it!=grplist.end();++it) - shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ; + for(auto it(grplist.begin());it!=grplist.end();++it) + shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ; - contextMnu.addMenu(&shareChannelMenu) ; - } + contextMnu.addMenu(&shareChannelMenu) ; + } - GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); + GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); - if(forumsDialog != NULL) - { - shareForumMenu.setIcon(QIcon(IMAGE_FORUMS)); + if(forumsDialog != NULL) + { + shareForumMenu.setIcon(QIcon(IMAGE_FORUMS)); - std::map grp_metas ; - forumsDialog->getGroupList(grp_metas) ; + std::map grp_metas ; + forumsDialog->getGroupList(grp_metas) ; - std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. + std::vector > grplist ; // I dont use a std::map because two or more channels may have the same name. - for(auto it(grp_metas.begin());it!=grp_metas.end();++it) - if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) - grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); + for(auto it(grp_metas.begin());it!=grp_metas.end();++it) + if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags)) + grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId)); - std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; + std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ; - for(auto it(grplist.begin());it!=grplist.end();++it) - shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ; + for(auto it(grplist.begin());it!=grplist.end();++it) + shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ; - contextMnu.addMenu(&shareForumMenu) ; - } - } + contextMnu.addMenu(&shareForumMenu) ; + } + } - contextMnu.exec(QCursor::pos()) ; + contextMnu.exec(QCursor::pos()) ; } void LocalSharedFilesDialog::shareOnChannel() { - RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); + RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); - GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); + GxsChannelDialog *channelDialog = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); - if(channelDialog == NULL) - return ; + if(channelDialog == NULL) + return ; - std::list files_info ; + std::list files_info ; - QList file_links_list ; - bool has_unhashed_files ; + QList file_links_list ; + bool has_unhashed_files ; - copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; + copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; - channelDialog->shareOnChannel(groupId,file_links_list) ; + channelDialog->shareOnChannel(groupId,file_links_list) ; } void LocalSharedFilesDialog::shareInForum() { - RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); + RsGxsGroupId groupId(qobject_cast(sender())->data().toString().toStdString()); - GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); + GxsForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); - if(forumsDialog == NULL) - return ; + if(forumsDialog == NULL) + return ; - std::list files_info ; + std::list files_info ; - QList file_links_list ; - bool has_unhashed_files ; + QList file_links_list ; + bool has_unhashed_files ; - copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; + copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ; - forumsDialog->shareInMessage(groupId,file_links_list) ; + forumsDialog->shareInMessage(groupId,file_links_list) ; } //============================================================================ @@ -1304,90 +1309,90 @@ LocalSharedFilesDialog::tryToAddNewAssotiation() void SharedFilesDialog::indicatorChanged(int index) { - static uint32_t correct_indicator[4] = { IND_ALWAYS,IND_LAST_DAY,IND_LAST_WEEK,IND_LAST_MONTH } ; + static uint32_t correct_indicator[4] = { IND_ALWAYS,IND_LAST_DAY,IND_LAST_WEEK,IND_LAST_MONTH } ; - model->changeAgeIndicator(correct_indicator[index]); + model->changeAgeIndicator(correct_indicator[index]); - ui.dirTreeView->update(ui.dirTreeView->rootIndex()); + ui.dirTreeView->update(ui.dirTreeView->rootIndex()); - if (correct_indicator[index] != IND_ALWAYS) - ui.dirTreeView->sortByColumn(COLUMN_AGE, Qt::AscendingOrder); - else - ui.dirTreeView->sortByColumn(COLUMN_NAME, Qt::AscendingOrder); + if (correct_indicator[index] != IND_ALWAYS) + ui.dirTreeView->sortByColumn(COLUMN_AGE, Qt::AscendingOrder); + else + ui.dirTreeView->sortByColumn(COLUMN_NAME, Qt::AscendingOrder); - updateDisplay() ; + updateDisplay() ; } void SharedFilesDialog::onFilterTextEdited() { - QString text = ui.filterPatternLineEdit->text(); + QString text = ui.filterPatternLineEdit->text(); - if (text.isEmpty()) { - ui.filterClearButton->hide(); - } else { - ui.filterClearButton->show(); - } + if (text.isEmpty()) { + ui.filterClearButton->hide(); + } else { + ui.filterClearButton->show(); + } - if (text == lastFilterString) { - ui.filterStartButton->hide(); - } else { - ui.filterStartButton->show(); - } + if (text == lastFilterString) { + ui.filterStartButton->hide(); + } else { + ui.filterStartButton->show(); + } - if(text.length() > 0 && text.length() < 3) - { - ui.filterStartButton->setEnabled(false) ; - ui.filterPatternFrame->setToolTip(tr("Search string should be at least 3 characters long.")) ; - return ; - } + if(text.length() > 0 && text.length() < 3) + { + ui.filterStartButton->setEnabled(false) ; + ui.filterPatternFrame->setToolTip(tr("Search string should be at least 3 characters long.")) ; + return ; + } - ui.filterStartButton->setEnabled(true) ; - ui.filterPatternFrame->setToolTip(QString()); + ui.filterStartButton->setEnabled(true) ; + ui.filterPatternFrame->setToolTip(QString()); - //FilterItems(); + //FilterItems(); #ifndef DISABLE_SEARCH_WHILE_TYPING - mFilterTimer->start( 500 ); // This will fire filterRegExpChanged after 500 ms. - // If the user types something before it fires, the timer restarts counting + mFilterTimer->start( 500 ); // This will fire filterRegExpChanged after 500 ms. + // If the user types something before it fires, the timer restarts counting #endif } #ifdef DEPRECATED_CODE void SharedFilesDialog::filterRegExpChanged() { - QString text = ui.filterPatternLineEdit->text(); + QString text = ui.filterPatternLineEdit->text(); - if(text.length() > 0 && proxyModel == tree_proxyModel) - { - std::list result_list ; - std::list keywords; + if(text.length() > 0 && proxyModel == tree_proxyModel) + { + std::list result_list ; + std::list keywords; - QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + QStringList lst = text.split(" ",QString::SkipEmptyParts) ; - for(auto it(lst.begin());it!=lst.end();++it) - keywords.push_back((*it).toStdString()); + for(auto it(lst.begin());it!=lst.end();++it) + keywords.push_back((*it).toStdString()); - FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; + FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; - if(keywords.size() > 1) - { - RsRegularExpression::NameExpression exp(RsRegularExpression::ContainsAllStrings,keywords,true); - rsFiles->SearchBoolExp(&exp,result_list, flags) ; - } - else - rsFiles->SearchKeywords(keywords,result_list, flags) ; + if(keywords.size() > 1) + { + RsRegularExpression::NameExpression exp(RsRegularExpression::ContainsAllStrings,keywords,true); + rsFiles->SearchBoolExp(&exp,result_list, flags) ; + } + else + rsFiles->SearchKeywords(keywords,result_list, flags) ; - uint32_t nb_results = result_list.size(); + uint32_t nb_results = result_list.size(); - if(nb_results > MAX_SEARCH_RESULTS) - { - ui.filterStartButton->setEnabled(false) ; - ui.filterPatternFrame->setToolTip(tr("More than 3000 results. Add more/longer search words to select less.")) ; - return ; - } - } + if(nb_results > MAX_SEARCH_RESULTS) + { + ui.filterStartButton->setEnabled(false) ; + ui.filterPatternFrame->setToolTip(tr("More than 3000 results. Add more/longer search words to select less.")) ; + return ; + } + } - ui.filterStartButton->setEnabled(true) ; - ui.filterPatternFrame->setToolTip(QString()); + ui.filterStartButton->setEnabled(true) ; + ui.filterPatternFrame->setToolTip(QString()); } #endif @@ -1403,25 +1408,25 @@ void SharedFilesDialog::clearFilter() /* clear Filter */ void SharedFilesDialog::startFilter() { - ui.filterStartButton->hide(); - lastFilterString = ui.filterPatternLineEdit->text(); + ui.filterStartButton->hide(); + lastFilterString = ui.filterPatternLineEdit->text(); - FilterItems(); + FilterItems(); } void SharedFilesDialog::updateDirTreeView() { - if (model == flat_model) - { - size_t maxSize = 0; - FlatStyle_RDM* flat = dynamic_cast(flat_model); - if (flat && flat->isMaxRefsTableSize(&maxSize)) - { - ui.dirTreeView->setToolTip(tr("Warning: You reach max (%1) files in flat list. No more will be added.").arg(maxSize)); - return; - } - } - ui.dirTreeView->setToolTip(""); + if (model == flat_model) + { + size_t maxSize = 0; + FlatStyle_RDM* flat = dynamic_cast(flat_model); + if (flat && flat->isMaxRefsTableSize(&maxSize)) + { + ui.dirTreeView->setToolTip(tr("Warning: You reach max (%1) files in flat list. No more will be added.").arg(maxSize)); + return; + } + } + ui.dirTreeView->setToolTip(""); } //#define DEBUG_SHARED_FILES_DIALOG @@ -1435,90 +1440,90 @@ void SharedFilesDialog::updateDirTreeView() void recursMakeVisible(QTreeView *tree,const QSortFilterProxyModel *proxyModel,const QModelIndex& indx,uint32_t depth,const std::vector >& pointers,QList& hidden_list) { #ifdef DEBUG_SHARED_FILES_DIALOG - for(uint32_t i=0;isetRowHidden(indx.row(), indx.parent(), false) ; + tree->setRowHidden(indx.row(), indx.parent(), false) ; #ifdef EXPAND_WHILE_SEARCHING - tree->setExpanded(indx,true) ; + tree->setExpanded(indx,true) ; #endif - bool found = false ; + bool found = false ; for (int row = 0; row < rowCount; ++row) - { - QModelIndex child_index = indx.child(row,0); + { + QModelIndex child_index = indx.child(row,0); - if(ptrs.find(proxyModel->mapToSource(child_index).internalPointer()) != ptrs.end()) - { + if(ptrs.find(proxyModel->mapToSource(child_index).internalPointer()) != ptrs.end()) + { #ifdef DEBUG_SHARED_FILES_DIALOG - for(uint32_t i=0;imapToSource(child_index).internalPointer() << " visible" << std::endl; + for(uint32_t i=0;imapToSource(child_index).internalPointer() << " visible" << std::endl; #endif - recursMakeVisible(tree,proxyModel,child_index,depth+1,pointers,hidden_list) ; - found = true ; - } - else - { - tree->setRowHidden(child_index.row(), indx, true) ; - hidden_list.push_back(proxyModel->mapToSource(child_index)) ; + recursMakeVisible(tree,proxyModel,child_index,depth+1,pointers,hidden_list) ; + found = true ; + } + else + { + tree->setRowHidden(child_index.row(), indx, true) ; + hidden_list.push_back(proxyModel->mapToSource(child_index)) ; #ifdef EXPAND_WHILE_SEARCHING - tree->setExpanded(child_index,false) ; + tree->setExpanded(child_index,false) ; #endif #ifdef DEBUG_SHARED_FILES_DIALOG - for(uint32_t i=0;imapToSource(child_index).internalPointer() << " hidden" << std::endl; + for(uint32_t i=0;imapToSource(child_index).internalPointer() << " hidden" << std::endl; #endif - } - } + } + } - if(!found && depth == 0) - { - tree->setRowHidden(indx.row(), indx.parent(), true) ; - hidden_list.push_back(proxyModel->mapToSource(indx)) ; - } + if(!found && depth == 0) + { + tree->setRowHidden(indx.row(), indx.parent(), true) ; + hidden_list.push_back(proxyModel->mapToSource(indx)) ; + } } void SharedFilesDialog::restoreInvisibleItems() { - std::cerr << "Restoring " << mHiddenIndexes.size() << " invisible indexes" << std::endl; + std::cerr << "Restoring " << mHiddenIndexes.size() << " invisible indexes" << std::endl; - for(QList::const_iterator it(mHiddenIndexes.begin());it!=mHiddenIndexes.end();++it) - { - QModelIndex indx = proxyModel->mapFromSource(*it); + for(QList::const_iterator it(mHiddenIndexes.begin());it!=mHiddenIndexes.end();++it) + { + QModelIndex indx = proxyModel->mapFromSource(*it); - if(indx.isValid()) - ui.dirTreeView->setRowHidden(indx.row(), indx.parent(), false) ; - } + if(indx.isValid()) + ui.dirTreeView->setRowHidden(indx.row(), indx.parent(), false) ; + } - mHiddenIndexes.clear(); + mHiddenIndexes.clear(); } #endif class QCursorContextBlocker { - public: - QCursorContextBlocker(QWidget *w) - : mW(w) - { - mW->setCursor(Qt::WaitCursor); - mW->blockSignals(true) ; - } + public: + QCursorContextBlocker(QWidget *w) + : mW(w) + { + mW->setCursor(Qt::WaitCursor); + mW->blockSignals(true) ; + } - ~QCursorContextBlocker() - { - mW->setCursor(Qt::ArrowCursor); - mW->blockSignals(false) ; - } + ~QCursorContextBlocker() + { + mW->setCursor(Qt::ArrowCursor); + mW->blockSignals(false) ; + } - private: - QWidget *mW ; + private: + QWidget *mW ; }; void SharedFilesDialog::FilterItems() @@ -1528,68 +1533,68 @@ void SharedFilesDialog::FilterItems() return; #endif - QString text = ui.filterPatternLineEdit->text(); + QString text = ui.filterPatternLineEdit->text(); - if(mLastFilterText == text) // do not filter again if we already did. This is an optimization - { + if(mLastFilterText == text) // do not filter again if we already did. This is an optimization + { #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "Last text is equal to text. skipping" << std::endl; + std::cerr << "Last text is equal to text. skipping" << std::endl; #endif - return ; - } + return ; + } #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "New last text. Performing the filter on string \"" << text.toStdString() << "\"" << std::endl; + std::cerr << "New last text. Performing the filter on string \"" << text.toStdString() << "\"" << std::endl; #endif - mLastFilterText = text ; + mLastFilterText = text ; - QCursorContextBlocker q(ui.dirTreeView) ; + QCursorContextBlocker q(ui.dirTreeView) ; - QCoreApplication::processEvents() ; + QCoreApplication::processEvents() ; - std::list result_list ; - uint32_t found = 0 ; + std::list result_list ; + uint32_t found = 0 ; - if(text == "") - { - model->filterItems(std::list(),found) ; - model->update() ; - return ; - } + if(text == "") + { + model->filterItems(std::list(),found) ; + model->update() ; + return ; + } - if(text.length() < 3) - return ; + if(text.length() < 3) + return ; - //FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; - QStringList lst = text.split(" ",QString::SkipEmptyParts) ; - std::list keywords ; + //FileSearchFlags flags = isRemote()?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL; + QStringList lst = text.split(" ",QString::SkipEmptyParts) ; + std::list keywords ; - for(auto it(lst.begin());it!=lst.end();++it) - keywords.push_back((*it).toStdString()); + for(auto it(lst.begin());it!=lst.end();++it) + keywords.push_back((*it).toStdString()); - model->filterItems(keywords,found) ; - model->update() ; + model->filterItems(keywords,found) ; + model->update() ; - if(found > 0) - expandAll(); + if(found > 0) + expandAll(); - if(found == 0) - ui.filterPatternFrame->setToolTip(tr("No result.")) ; - else if(found > MAX_SEARCH_RESULTS) - ui.filterPatternFrame->setToolTip(tr("More than %1 results. Add more/longer search words to select less.").arg(MAX_SEARCH_RESULTS)) ; - else - ui.filterPatternFrame->setToolTip(tr("Found %1 results.").arg(found)) ; + if(found == 0) + ui.filterPatternFrame->setToolTip(tr("No result.")) ; + else if(found > MAX_SEARCH_RESULTS) + ui.filterPatternFrame->setToolTip(tr("More than %1 results. Add more/longer search words to select less.").arg(MAX_SEARCH_RESULTS)) ; + else + ui.filterPatternFrame->setToolTip(tr("Found %1 results.").arg(found)) ; #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << found << " results found by search." << std::endl; + std::cerr << found << " results found by search." << std::endl; #endif } void SharedFilesDialog::removeExtraFile() { - std::list files_info ; + std::list files_info ; - model->getFileInfoFromIndexList(getSelected(),files_info); + model->getFileInfoFromIndexList(getSelected(),files_info); for(auto it(files_info.begin());it!=files_info.end();++it) { @@ -1602,17 +1607,17 @@ void SharedFilesDialog::removeExtraFile() #ifdef DEPRECATED_CODE bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int /*level*/) { - if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive)) - { - ui.dirTreeView->setRowHidden(index.row(), index.parent(), false); - return false ; - } - else - { - ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); - mHiddenIndexes.push_back(proxyModel->mapToSource(index)); - return true ; - } + if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive)) + { + ui.dirTreeView->setRowHidden(index.row(), index.parent(), false); + return false ; + } + else + { + ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); + mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + return true ; + } } bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString &text, int level) @@ -1641,10 +1646,10 @@ bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString if (visible || visibleChildCount) { ui.dirTreeView->setRowHidden(index.row(), index.parent(), false); } else { - { + { ui.dirTreeView->setRowHidden(index.row(), index.parent(), true); - mHiddenIndexes.push_back(proxyModel->mapToSource(index)); - } + mHiddenIndexes.push_back(proxyModel->mapToSource(index)); + } } return (visible || visibleChildCount); diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index 5206e1d06..6ee989170 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -38,10 +38,10 @@ class SharedFilesDialog : public RsAutoUpdatePage public: /** Default Constructor */ - SharedFilesDialog(RetroshareDirModel *tree_model,RetroshareDirModel *flat_model,QWidget *parent = 0); + SharedFilesDialog(bool remote_mode,QWidget *parent = 0); /** Default Destructor */ - ~SharedFilesDialog() {} + ~SharedFilesDialog() ; virtual void hideEvent(QHideEvent *) ; virtual void showEvent(QShowEvent *) ; From 243ba595f05fd3311368ab8b8be5f727acd94d09 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Aug 2020 13:41:21 +0200 Subject: [PATCH 04/21] added missing virtual destructors possibly causing memory leaks --- retroshare-gui/src/gui/common/FriendListModel.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.h b/retroshare-gui/src/gui/common/FriendListModel.h index 5e8d84930..871dc14b9 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.h +++ b/retroshare-gui/src/gui/common/FriendListModel.h @@ -39,8 +39,16 @@ public: explicit RsFriendListModel(QObject *parent = NULL); ~RsFriendListModel(){} - class RsNodeDetails: public RsPeerDetails {};// in the near future, there will be a specific class for Profile/Node details in replacement of RsPeerDetails - class RsProfileDetails: public RsPeerDetails {}; + class RsNodeDetails: public RsPeerDetails + { + public: + virtual ~RsNodeDetails() {} + };// in the near future, there will be a specific class for Profile/Node details in replacement of RsPeerDetails + class RsProfileDetails: public RsPeerDetails + { + public: + virtual ~RsProfileDetails() {} + }; struct HierarchicalGroupInformation { @@ -55,6 +63,7 @@ public: struct HierarchicalNodeInformation { HierarchicalNodeInformation() : last_update_ts(0) {} + virtual ~HierarchicalNodeInformation() {} rstime_t last_update_ts; RsNodeDetails node_info; From bb6706e996cb97d6717725383b4009512df28245 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Aug 2020 18:54:00 +0200 Subject: [PATCH 05/21] added missing destructor in MsgMetaCache --- libretroshare/src/gxs/rsdataservice.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libretroshare/src/gxs/rsdataservice.h b/libretroshare/src/gxs/rsdataservice.h index 56dc8dea6..bf532afae 100644 --- a/libretroshare/src/gxs/rsdataservice.h +++ b/libretroshare/src/gxs/rsdataservice.h @@ -39,6 +39,14 @@ template class t_MetaDataCache { public: t_MetaDataCache() : mCache_ContainsAllMetas(false) {} + virtual ~t_MetaDataCache() + { + for(auto it: mMetas) + delete it.second; + + for(auto it: mOldCachedItems) + delete it.second; + } bool isCacheUpToDate() const { return mCache_ContainsAllMetas ; } void setCacheUpToDate(bool b) { mCache_ContainsAllMetas = b; } From dcbcc95e4187de4ab3b297861b3b8068db1ad0d5 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Aug 2020 21:11:11 +0200 Subject: [PATCH 06/21] fixed missing delete of Files delegate in channel model --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 3 ++- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 2a44ba985..d07f4ad74 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -245,7 +245,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->channelPostFiles_TV->sortByColumn(0, Qt::AscendingOrder); ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel()); - ui->channelFiles_TV->setItemDelegate(new ChannelPostFilesDelegate()); + ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate()); ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected")); ui->channelFiles_TV->setSortingEnabled(true); ui->channelFiles_TV->sortByColumn(0, Qt::AscendingOrder); @@ -631,6 +631,7 @@ GxsChannelPostsWidgetWithModel::~GxsChannelPostsWidgetWithModel() processSettings(false); delete(mAutoDownloadAction); + delete mFilesDelegate; delete ui; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index be2ccdf6c..5fb04bb6f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -174,6 +174,7 @@ private: RsGxsChannelPostFilesModel *mChannelPostFilesModel; RsGxsChannelPostFilesModel *mChannelFilesModel; ChannelPostDelegate *mChannelPostsDelegate; + ChannelPostFilesDelegate *mFilesDelegate; RsGxsMessageId mSelectedPost; From 209355b9a5d39817588bb57d7b714c43d6e5b72a Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Aug 2020 22:17:52 +0200 Subject: [PATCH 07/21] converted all calls to QIcon("somefile.png") into FilesDefs::getIconFromQtResourcePath("somefile.png") to save memory duplicated by Qt --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 35 ++++----- retroshare-gui/src/gui/Identity/IdDialog.cpp | 28 ++++---- .../src/gui/Posted/PostedDialog.cpp | 2 +- .../src/gui/chat/ChatLobbyDialog.cpp | 10 +-- .../src/gui/chat/ChatLobbyUserNotify.cpp | 7 +- retroshare-gui/src/gui/chat/ChatTabWidget.cpp | 9 +-- .../src/gui/chat/ChatUserNotify.cpp | 5 +- retroshare-gui/src/gui/chat/ChatWidget.cpp | 4 +- .../src/gui/chat/PopupChatDialog.cpp | 5 +- .../src/gui/chat/PopupChatWindow.cpp | 11 +-- .../src/gui/chat/PopupDistantChatDialog.cpp | 9 +-- retroshare-gui/src/gui/common/Emoticons.cpp | 7 +- retroshare-gui/src/gui/common/FriendList.cpp | 40 +++++------ .../src/gui/common/FriendSelectionWidget.cpp | 11 +-- .../src/gui/common/GroupFlagsWidget.cpp | 19 +++-- .../src/gui/common/GroupFlagsWidget.h | 2 +- .../src/gui/common/GroupTreeWidget.cpp | 5 +- .../src/gui/common/LineEditClear.cpp | 8 +-- .../src/gui/common/MimeTextEdit.cpp | 5 +- .../src/gui/common/NewFriendList.cpp | 35 ++++----- .../src/gui/common/PopularityDefs.cpp | 13 ++-- .../src/gui/common/RsCollectionDialog.cpp | 3 +- .../src/gui/common/SubscribeToolButton.cpp | 7 +- .../src/gui/connect/ConnectFriendWizard.cpp | 5 +- .../src/gui/connect/PGPKeyDialog.cpp | 5 +- retroshare-gui/src/gui/elastic/elnode.cpp | 7 +- .../src/gui/feeds/GxsChannelGroupItem.cpp | 5 +- .../src/gui/feeds/GxsForumGroupItem.cpp | 5 +- .../src/gui/feeds/GxsForumMsgItem.cpp | 5 +- retroshare-gui/src/gui/feeds/MsgItem.cpp | 5 +- .../src/gui/feeds/NewsFeedUserNotify.cpp | 3 +- retroshare-gui/src/gui/feeds/PeerItem.cpp | 5 +- .../src/gui/feeds/PostedGroupItem.cpp | 5 +- .../src/gui/feeds/SecurityIpItem.cpp | 5 +- retroshare-gui/src/gui/feeds/SecurityItem.cpp | 5 +- .../src/gui/gxs/GxsCommentTreeWidget.cpp | 8 +-- .../src/gui/gxs/GxsGroupFrameDialog.cpp | 72 +++++++++---------- retroshare-gui/src/gui/gxs/GxsIdChooser.cpp | 5 +- retroshare-gui/src/gui/gxs/GxsIdDetails.cpp | 33 ++++----- .../src/gui/gxs/GxsIdTreeWidgetItem.cpp | 2 +- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 4 +- .../src/gui/gxschannels/GxsChannelDialog.cpp | 12 ++-- .../gui/gxschannels/GxsChannelPostsWidget.cpp | 4 +- .../gui/gxsforums/GxsForumThreadWidget.cpp | 2 +- .../src/gui/gxsforums/GxsForumsDialog.cpp | 4 +- .../src/gui/msgs/MessageComposer.cpp | 17 ++--- .../src/gui/msgs/MessageUserNotify.cpp | 5 +- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 8 +-- retroshare-gui/src/gui/msgs/MessageWindow.cpp | 7 +- .../src/gui/msgs/MessagesDialog.cpp | 30 ++++---- retroshare-gui/src/gui/notifyqt.cpp | 3 +- .../src/gui/profile/ProfileManager.cpp | 3 +- .../src/gui/settings/AppearancePage.cpp | 3 +- .../src/gui/settings/FileAssociationsPage.cpp | 7 +- .../src/gui/settings/ServerPage.cpp | 6 +- .../src/gui/settings/rsettingswin.h | 3 +- .../gui/statistics/GlobalRouterStatistics.cpp | 2 +- .../src/gui/statistics/StatisticsWindow.cpp | 17 ++--- .../src/gui/statusbar/SoundStatus.cpp | 3 +- .../src/gui/statusbar/SysTrayStatus.cpp | 3 +- .../src/gui/unfinished/ApplicationWindow.cpp | 8 +-- retroshare-gui/src/main.cpp | 7 +- retroshare-gui/src/rshare.cpp | 3 +- 63 files changed, 330 insertions(+), 291 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index bd802bae4..475495674 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -34,6 +34,7 @@ #include "gui/settings/rsharesettings.h" #include "util/HandleRichText.h" #include "util/QtVersion.h" +#include "gui/common/FilesDefs.h" #include "retroshare/rsmsgs.h" #include "retroshare/rspeers.h" @@ -281,7 +282,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) QMenu contextMnu(this); if (item && item->type() == TYPE_FOLDER) { - QAction *action = contextMnu.addAction(QIcon(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()); } @@ -291,7 +292,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) rsIdentity->getOwnIds(own_identities) ; if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) - contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Leave this room"), this, SLOT(unsubscribeItem())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_UNSUBSCRIBE), tr("Leave this room"), this, SLOT(unsubscribeItem())); else { QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); @@ -306,18 +307,18 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) if(own_identities.empty()) { if(removed) - contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Create a non anonymous identity and enter this room"), this, SLOT(createIdentityAndSubscribe())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Create a non anonymous identity and enter this room"), this, SLOT(createIdentityAndSubscribe())); else - contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Create an identity and enter this chat room"), this, SLOT(createIdentityAndSubscribe())); + 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(QIcon(IMAGE_SUBSCRIBE), tr("Enter this chat room"), this, SLOT(subscribeChatLobbyAs())); + 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(QIcon(IMAGE_SUBSCRIBE),tr("Enter this chat room as...")) ; + 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) { @@ -344,7 +345,7 @@ void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Add Auto Subscribe"), this, SLOT(autoSubscribeItem())); #endif - contextMnu.addAction(QIcon(IMAGE_COPYRSLINK), tr("Copy RetroShare Link"), this, SLOT(copyItemLink())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYRSLINK), tr("Copy RetroShare Link"), this, SLOT(copyItemLink())); } contextMnu.addSeparator();//------------------------------------------------------------------- @@ -435,7 +436,7 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d) ChatLobbyInfo linfo ; if(rsMsgs->getChatLobbyInfo(id,linfo)) - _lobby_infos[id].default_icon = (linfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC):QIcon(IMAGE_PRIVATE) ; + _lobby_infos[id].default_icon = (linfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC):FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE) ; else std::cerr << "(EE) cannot find info for room " << std::hex << id << std::dec << std::endl; } @@ -615,7 +616,7 @@ void ChatLobbyWidget::updateDisplay() if (item == NULL) { item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY); - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); lobby_item->addChild(item); } @@ -623,7 +624,7 @@ void ChatLobbyWidget::updateDisplay() { if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool() != subscribed) { // Replace icon - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); } } if (!icon.isNull()) { @@ -683,12 +684,12 @@ void ChatLobbyWidget::updateDisplay() if (item == NULL) { item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY); - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); itemParent->addChild(item); } else { if (!item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) { // Replace icon - icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + icon = (lobby.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); } } if (!icon.isNull()) { @@ -996,7 +997,7 @@ void ChatLobbyWidget::updateTypingStatus(ChatLobbyId id) if(item != NULL) { - item->setIcon(COLUMN_NAME,QIcon(IMAGE_TYPING)) ; + item->setIcon(COLUMN_NAME,FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING)) ; _lobby_infos[id].last_typing_event = time(NULL) ; QTimer::singleShot(5000,this,SLOT(resetLobbyTreeIcons())) ; @@ -1008,7 +1009,7 @@ void ChatLobbyWidget::updatePeerLeaving(ChatLobbyId id) if(item != NULL) { - item->setIcon(COLUMN_NAME,QIcon(IMAGE_PEER_LEAVING)) ; + item->setIcon(COLUMN_NAME,FilesDefs::getIconFromQtResourcePath(IMAGE_PEER_LEAVING)) ; _lobby_infos[id].last_typing_event = time(NULL) ; QTimer::singleShot(5000,this,SLOT(resetLobbyTreeIcons())) ; @@ -1020,7 +1021,7 @@ void ChatLobbyWidget::updatePeerEntering(ChatLobbyId id) if(item != NULL) { - item->setIcon(COLUMN_NAME,QIcon(IMAGE_PEER_ENTERING)) ; + item->setIcon(COLUMN_NAME,FilesDefs::getIconFromQtResourcePath(IMAGE_PEER_ENTERING)) ; _lobby_infos[id].last_typing_event = time(NULL) ; QTimer::singleShot(5000,this,SLOT(resetLobbyTreeIcons())) ; @@ -1105,7 +1106,7 @@ void ChatLobbyWidget::updateCurrentLobby() if(_lobby_infos.find(id) != _lobby_infos.end()) { int iPrivacyLevel= item->parent()->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt(); - QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); + QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(IMAGE_PUBLIC) : FilesDefs::getIconFromQtResourcePath(IMAGE_PRIVATE); _lobby_infos[id].default_icon = icon ; item->setIcon(COLUMN_NAME, icon) ; } @@ -1129,7 +1130,7 @@ void ChatLobbyWidget::updateMessageChanged(bool incoming, ChatLobbyId id, QDateT if(bIsCurrentItem) return ; - _lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ; + _lobby_infos[id].default_icon = FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE) ; QTreeWidgetItem *item = getTreeWidgetItem(id) ; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index d87f1d6e7..f66f9d6af 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -321,10 +321,10 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog) connect(idTWHAction, SIGNAL(toggled(bool)), this, SLOT(filterToggled(bool))); idTWHMenu->addAction(idTWHAction); - QAction *CreateIDAction = new QAction(QIcon(":/icons/png/person.png"),tr("Create new Identity"), this); + QAction *CreateIDAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/person.png"),tr("Create new Identity"), this); connect(CreateIDAction, SIGNAL(triggered()), this, SLOT(addIdentity())); - QAction *CreateCircleAction = new QAction(QIcon(":/icons/png/circles.png"),tr("Create new circle"), this); + QAction *CreateCircleAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/circles.png"),tr("Create new circle"), this); connect(CreateCircleAction, SIGNAL(triggered()), this, SLOT(createExternalCircle())); QMenu *menu = new QMenu(); @@ -1017,11 +1017,11 @@ void IdDialog::CircleListCustomPopupMenu( QPoint ) #endif if(group_flags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) { - contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Circle"), this, SLOT(showEditExistingCircle())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Circle"), this, SLOT(showEditExistingCircle())); am_I_circle_admin = true ; } else - contextMnu.addAction(QIcon(IMAGE_INFO), tr("See details"), this, SLOT(showEditExistingCircle())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_INFO), tr("See details"), this, SLOT(showEditExistingCircle())); #ifdef CIRCLE_MEMBERSHIP_CATEGORIES } #endif @@ -1109,9 +1109,9 @@ void IdDialog::CircleListCustomPopupMenu( QPoint ) QAction *action ; if(is_circle) - action = new QAction(QIcon(image_names[i]), menu_titles[i] + " " + id_name,this) ; + action = new QAction(FilesDefs::getIconFromQtResourcePath(image_names[i]), menu_titles[i] + " " + id_name,this) ; else - action = new QAction(QIcon(image_names[i]), menu_titles[i],this) ; + action = new QAction(FilesDefs::getIconFromQtResourcePath(image_names[i]), menu_titles[i],this) ; if(i <2) QObject::connect(action,SIGNAL(triggered()), this, SLOT(acceptCircleSubscription())); @@ -1134,7 +1134,7 @@ void IdDialog::CircleListCustomPopupMenu( QPoint ) else id_name = tr("for identity ")+QString::fromStdString(ids[i][j].toStdString()) ; - QAction *action = new QAction(QIcon(image_names[i]), id_name,this) ; + QAction *action = new QAction(FilesDefs::getIconFromQtResourcePath(image_names[i]), id_name,this) ; if(i <2) QObject::connect(action,SIGNAL(triggered()), this, SLOT(acceptCircleSubscription())); @@ -2195,7 +2195,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) { if(own_identities.size() <= 1) { - QAction *action = contextMenu->addAction(QIcon(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); + QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); if(own_identities.empty()) action->setEnabled(false) ; @@ -2204,7 +2204,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } else { - QMenu *mnu = contextMenu->addMenu(QIcon(":/icons/png/chats.png"),tr("Chat with this person as...")) ; + QMenu *mnu = contextMenu->addMenu(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"),tr("Chat with this person as...")) ; for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) { @@ -2222,7 +2222,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } } // always allow to send messages - contextMenu->addAction(QIcon(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); contextMenu->addSeparator(); @@ -2233,18 +2233,18 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; if(n_is_not_a_contact == 0) - contextMenu->addAction(QIcon(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/cancel.png"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); contextMenu->addSeparator(); if(n_positive_reputations == 0) // only unban when all items are banned - contextMenu->addAction(QIcon(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); if(n_neutral_reputations == 0) // only unban when all items are banned - contextMenu->addAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); if(n_negative_reputations == 0) - contextMenu->addAction(QIcon(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); } if(one_item_owned_by_you && n_selected_items==1) diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp index 6c2772276..fa5826151 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -255,7 +255,7 @@ void PostedDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupDa groupItemInfo.icon = image; } else - groupItemInfo.icon = QIcon(":icons/png/postedlinks.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/postedlinks.png"); groupItemInfo.description = QString::fromUtf8(postedGroupData->mDescription.c_str()); } diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index b45c448fe..bfd2ad379 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -92,11 +92,11 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch); muteAct = new QAction(QIcon(), tr("Mute participant"), this); - voteNegativeAct = new QAction(QIcon(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this); - voteNeutralAct = new QAction(QIcon(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this); - votePositiveAct = new QAction(QIcon(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this); - distantChatAct = new QAction(QIcon(":/icons/png/chats.png"), tr("Start private chat"), this); - sendMessageAct = new QAction(QIcon(":/icons/mail/write-mail.png"), tr("Send Message"), this); + voteNegativeAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this); + voteNeutralAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this); + votePositiveAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Give positive opinion"), this); + distantChatAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Start private chat"), this); + sendMessageAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send Message"), this); showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); QActionGroup *sortgrp = new QActionGroup(this); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp index 81cb47846..64798a011 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp @@ -23,6 +23,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include "ChatLobbyUserNotify.h" #include "gui/ChatLobbyWidget.h" @@ -104,12 +105,12 @@ void ChatLobbyUserNotify::setTextCaseSensitive(bool value) QIcon ChatLobbyUserNotify::getIcon() { - return QIcon(":/icons/png/chat-lobbies.png"); + return FilesDefs::getIconFromQtResourcePath(":/icons/png/chat-lobbies.png"); } QIcon ChatLobbyUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/chat-lobbies-notify.png") : QIcon(":/icons/png/chat-lobbies.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/chat-lobbies-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/chat-lobbies.png"); } unsigned int ChatLobbyUserNotify::getNewCount() @@ -164,7 +165,7 @@ void ChatLobbyUserNotify::iconClicked() ChatLobbyInfo clInfo; if (rsMsgs->getChatLobbyInfo(clId,clInfo)) strLobbyName=QString::fromUtf8(clInfo.lobby_name.c_str()) ; - icoLobby=(clInfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(":/images/chat_red24.png") : QIcon(":/images/chat_x24.png"); + icoLobby=(clInfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? FilesDefs::getIconFromQtResourcePath(":/images/chat_red24.png") : FilesDefs::getIconFromQtResourcePath(":/images/chat_x24.png"); bFound=true; break; } diff --git a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp index ad15fb905..03357a3e4 100644 --- a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp @@ -22,6 +22,7 @@ #include +#include "gui/common/FilesDefs.h" #include "ChatTabWidget.h" #include "ui_ChatTabWidget.h" #include "ChatDialog.h" @@ -102,9 +103,9 @@ void ChatTabWidget::tabInfoChanged(ChatDialog *dialog) if (tab >= 0) { if (dialog->isTyping()) { setBlinking(tab, false); - setTabIcon(tab, QIcon(IMAGE_TYPING)); + setTabIcon(tab, FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING)); } else if (dialog->hasNewMessages()) { - setTabIcon(tab, QIcon(IMAGE_CHAT)); + setTabIcon(tab, FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT)); if (dialog->notifyBlink()) { setBlinking(tab, true); } else { @@ -148,9 +149,9 @@ void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon) if (icon) { if (isTyping) { - *icon = QIcon(IMAGE_TYPING); + *icon = FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING); } else if (hasNewMessage) { - *icon = QIcon(IMAGE_CHAT); + *icon = FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT); } else { cd = dynamic_cast(currentWidget()); if (cd && cd->hasPeerStatus()) { diff --git a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp index ecb563938..2e9fb2d1a 100644 --- a/retroshare-gui/src/gui/chat/ChatUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatUserNotify.cpp @@ -20,6 +20,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "ChatUserNotify.h" #include "gui/notifyqt.h" #include "gui/MainWindow.h" @@ -75,12 +76,12 @@ bool ChatUserNotify::hasSetting(QString *name, QString *group) QIcon ChatUserNotify::getIcon() { - return QIcon(":/images/chat.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/chat.png"); } QIcon ChatUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/network-notify.png") : QIcon(":/icons/png/network.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/network-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/network.png"); } unsigned int ChatUserNotify::getNewCount() diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 6c36a392b..5506dedfb 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -245,7 +245,7 @@ ChatWidget::ChatWidget(QWidget *parent) //#ifdef ENABLE_DISTANT_CHAT_AND_MSGS // contextMnu->addSeparator(); -// QAction *action = new QAction(QIcon(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this); +// QAction *action = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this); // connect(action, SIGNAL(triggered()), this, SLOT(pasteCreateMsgLink())); // ui->chatTextEdit->addContextMenuAction(action); //#endif @@ -1067,7 +1067,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx rsIdentity->getIdDetails(gxsId, details); bool isUnsigned = !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED); if(isUnsigned && ui->textBrowser->getShowImages()) { - QIcon icon = QIcon(":/icons/anonymous_blue_128.png"); + QIcon icon = FilesDefs::getIconFromQtResourcePath(":/icons/anonymous_blue_128.png"); int height = ui->textBrowser->fontMetrics().height()*0.8; QImage image(icon.pixmap(height,height).toImage()); QByteArray byteArray; diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 1591669f4..9cb422a8f 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -23,6 +23,7 @@ #include "PopupChatDialog.h" #include "PopupChatWindow.h" +#include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "gui/settings/RsharePeerSettings.h" #include "gui/notifyqt.h" @@ -149,10 +150,10 @@ void PopupChatDialog::showAvatarFrame(bool show) if (show) { ui.avatarFrameButton->setToolTip(tr("Hide Avatar")); - ui.avatarFrameButton->setIcon(QIcon(":images/hide_toolbox_frame.png")); + ui.avatarFrameButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/hide_toolbox_frame.png")); } else { ui.avatarFrameButton->setToolTip(tr("Show Avatar")); - ui.avatarFrameButton->setIcon(QIcon(":images/show_toolbox_frame.png")); + ui.avatarFrameButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/show_toolbox_frame.png")); } PeerSettings->setShowAvatarFrame(mChatId, show); diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index 6d6502c5f..6c1f9128d 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -24,6 +24,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include "PopupChatWindow.h" #include "ChatDialog.h" #include "gui/settings/rsharesettings.h" @@ -113,14 +114,14 @@ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WindowFlags f void PopupChatWindow::showContextMenu(QPoint) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(":/images/highlight.png"),tr("Choose window color..."),this,SLOT(setStyle())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/highlight.png"),tr("Choose window color..."),this,SLOT(setStyle())); if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) { if(tabbedWindow) - contextMnu.addAction(QIcon(":/images/tab-dock.png"),tr("Dock window"),this,SLOT(docTab())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-dock.png"),tr("Dock window"),this,SLOT(docTab())); - contextMnu.addAction(QIcon(":/images/tab-undock.png"),tr("Dock window"),this,SLOT(undockTab())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-undock.png"),tr("Dock window"),this,SLOT(undockTab())); } contextMnu.exec(QCursor::pos()); } @@ -295,9 +296,9 @@ void PopupChatWindow::calculateTitle(ChatDialog *dialog) QIcon icon; if (isTyping) { mBlinkIcon = QIcon(); - icon = QIcon(IMAGE_TYPING); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_TYPING); } else if (hasNewMessages) { - icon = QIcon(IMAGE_CHAT); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT); if (Settings->getChatFlags() & RS_CHAT_BLINK) { mBlinkIcon = icon; } else { diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index b93c2d438..ff02ebae2 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -26,6 +26,7 @@ #include +#include "gui/common/FilesDefs.h" #include #include #include @@ -112,7 +113,7 @@ void PopupDistantChatDialog::updateDisplay() { case RS_DISTANT_CHAT_STATUS_UNKNOWN: - _status_label->setIcon(QIcon(IMAGE_GRY_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_GRY_LED)); msg = tr("Remote status unknown."); _status_label->setToolTip(msg); getChatWidget()->updateStatusString("%1", msg, true); @@ -123,7 +124,7 @@ void PopupDistantChatDialog::updateDisplay() break ; case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl; - _status_label->setIcon(QIcon(IMAGE_RED_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_RED_LED)); _status_label->setToolTip( QObject::tr("Distant peer has closed the chat") ); getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true ); @@ -134,7 +135,7 @@ void PopupDistantChatDialog::updateDisplay() case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: - _status_label->setIcon(QIcon(IMAGE_YEL_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_YEL_LED)); msg = QObject::tr( "Tunnel is pending"); if(tinfo.pending_items > 0) @@ -147,7 +148,7 @@ void PopupDistantChatDialog::updateDisplay() break; case RS_DISTANT_CHAT_STATUS_CAN_TALK: - _status_label->setIcon(QIcon(IMAGE_GRN_LED)); + _status_label->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_GRN_LED)); msg = QObject::tr( "End-to-end encrypted conversation established"); _status_label->setToolTip(msg); getChatWidget()->unblockSending(); diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 347d88b6e..47a1d67bf 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -37,6 +37,7 @@ #include "Emoticons.h" #include "util/HandleRichText.h" #include "retroshare/rsinit.h" +#include "gui/common/FilesDefs.h" #define ICONNAME "groupicon.png" @@ -210,7 +211,7 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s smTab->setStyleSheet("QTabBar::tab { height: 44px; width: 44px; }"); if (groupName.right(4).toLower() == ".png") - smTab->addTab( tabGrpWidget, QIcon(groupName), ""); + smTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupName), ""); else smTab->addTab( tabGrpWidget, groupName); } else { @@ -371,9 +372,9 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * int index; if (groupDir.exists(ICONNAME)) //use groupicon.png if exists, else the first png as a group icon - index = smTab->addTab( tabGrpWidget, QIcon(groupDir.absoluteFilePath(ICONNAME)), ""); + index = smTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupDir.absoluteFilePath(ICONNAME)), ""); else - index = smTab->addTab( tabGrpWidget, QIcon(groupDir.entryInfoList(QDir::Files)[0].canonicalFilePath()), ""); + index = smTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupDir.entryInfoList(QDir::Files)[0].canonicalFilePath()), ""); smTab->setTabToolTip(index, groupName); } else { tabGrpWidget = smWidget; diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 967d8df5d..257a0349a 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -352,25 +352,25 @@ void FriendList::peerTreeWidgetCustomPopupMenu() { bool standard = c->data(COLUMN_DATA, ROLE_STANDARD).toBool(); #ifdef RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgfriend())); contextMenu->addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); - QAction *action = contextMenu->addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); + QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); action->setDisabled(standard); } break; case TYPE_GPG: { #ifdef RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message"), this, SLOT(msgfriend())); contextMenu->addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend())); - contextMenu->addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configurefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removefriend())); if(mShowGroups) { @@ -412,8 +412,8 @@ void FriendList::peerTreeWidgetCustomPopupMenu() } } - QMenu *groupsMenu = contextMenu->addMenu(QIcon(IMAGE_GROUP16), tr("Groups")); - groupsMenu->addAction(QIcon(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); + QMenu *groupsMenu = contextMenu->addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups")); + groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); if (addToGroupMenu || moveToGroupMenu || foundGroup) { if (addToGroupMenu) { @@ -445,24 +445,24 @@ void FriendList::peerTreeWidgetCustomPopupMenu() case TYPE_SSL: { #ifdef RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); - contextMenu->addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgfriend())); contextMenu->addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu->addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configurefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configurefriend())); if (type == TYPE_GPG || type == TYPE_SSL) { - contextMenu->addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendfriend())); } if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( RsPeerId(getRsId(c)) )) - contextMenu->addAction(QIcon(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectfriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectfriend())); - contextMenu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); //this is a SSL key - contextMenu->addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removefriend())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removefriend())); } } @@ -471,12 +471,12 @@ void FriendList::peerTreeWidgetCustomPopupMenu() contextMenu->addSeparator(); - QAction *action = contextMenu->addAction(QIcon(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); + QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); if (RSLinkClipboard::empty(RetroShareLink::TYPE_CERTIFICATE)) action->setDisabled(true); - contextMenu->addAction(QIcon(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); - contextMenu->addAction(QIcon(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); contextMenu = ui->peerTreeWidget->createStandardContextMenu(contextMenu); @@ -716,7 +716,7 @@ void FriendList::insertPeers() groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter); - groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP24)); + groupItem->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP24)); groupItem->setData(COLUMN_NAME, Qt::ForegroundRole, textColorGroup()); /* used to find back the item */ diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 4043fe424..d253691bf 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include "FriendSelectionWidget.h" @@ -219,7 +220,7 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons item->setData(COLUMN_NAME, Qt::ForegroundRole, textColorOnline); } - item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state))); + item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(state))); item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id.toStdString())); item->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); @@ -381,7 +382,7 @@ void FriendSelectionWidget::secured_fillList() groupItem->setFlags(Qt::ItemIsUserCheckable | groupItem->flags()); groupItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless); groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter); - groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP16)); + groupItem->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16)); groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id.toStdString())); @@ -454,7 +455,7 @@ void FriendSelectionWidget::secured_fillList() } gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags()); - gpgItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state))); + gpgItem->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(state))); gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString())); gpgItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1); @@ -773,7 +774,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); } - item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus))); + item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(gpgStatus))); item->setData(COLUMN_NAME, ROLE_SORT_STATE, gpgStatus); @@ -790,7 +791,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status) item->setData(COLUMN_NAME, Qt::ForegroundRole, QVariant()); } - item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status))); + item->setIcon(COLUMN_NAME, FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status))); item->setData(COLUMN_NAME, ROLE_SORT_STATE, status); diff --git a/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp b/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp index d4142f886..9b40df3d0 100644 --- a/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupFlagsWidget.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include "GroupFlagsWidget.h" @@ -54,12 +55,12 @@ GroupFlagsWidget::GroupFlagsWidget(QWidget *parent,FileStorageFlags flags) setMaximumSize(128 * QFontMetricsF(font()).height()/14.0,32 * QFontMetricsF(font()).height()/14.0) ; setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - _icons[2*INDEX_BROWSABLE+0] = new QIcon(FLAGS_BROWSABLE_OFF) ; - _icons[2*INDEX_BROWSABLE+1] = new QIcon(FLAGS_BROWSABLE_ON) ; - _icons[2*INDEX_ANON_SEARCH+0] = new QIcon(FLAGS_ANONYMOUS_SEARCH_OFF) ; - _icons[2*INDEX_ANON_SEARCH+1] = new QIcon(FLAGS_ANONYMOUS_SEARCH_ON) ; - _icons[2*INDEX_ANON_DL+0] = new QIcon(FLAGS_ANONYMOUS_DL_OFF) ; - _icons[2*INDEX_ANON_DL+1] = new QIcon(FLAGS_ANONYMOUS_DL_ON) ; + _icons[2*INDEX_BROWSABLE+0] = FilesDefs::getIconFromQtResourcePath(FLAGS_BROWSABLE_OFF) ; + _icons[2*INDEX_BROWSABLE+1] = FilesDefs::getIconFromQtResourcePath(FLAGS_BROWSABLE_ON) ; + _icons[2*INDEX_ANON_SEARCH+0] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_SEARCH_OFF) ; + _icons[2*INDEX_ANON_SEARCH+1] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_SEARCH_ON) ; + _icons[2*INDEX_ANON_DL+0] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_DL_OFF) ; + _icons[2*INDEX_ANON_DL+1] = FilesDefs::getIconFromQtResourcePath(FLAGS_ANONYMOUS_DL_ON) ; setLayout(_layout) ; @@ -136,7 +137,7 @@ void GroupFlagsWidget::update_button_state(bool b,int button_id) tip_on = ""; tip_off = ""; } - _buttons[button_id]->setIcon(*_icons[2*button_id+(int)b]) ; + _buttons[button_id]->setIcon(_icons[2*button_id+(int)b]) ; _buttons[button_id]->setToolTip(b?tip_on:tip_off) ; } @@ -183,10 +184,6 @@ void GroupFlagsWidget::update_BR_button(bool b) { update_button_state(b,INDEX_BR GroupFlagsWidget::~GroupFlagsWidget() { for(int i=0;i<3;++i) - { delete _buttons[i] ; - delete _icons[2*i+0] ; - delete _icons[2*i+1] ; - } } diff --git a/retroshare-gui/src/gui/common/GroupFlagsWidget.h b/retroshare-gui/src/gui/common/GroupFlagsWidget.h index 4703d124d..d4ef95295 100644 --- a/retroshare-gui/src/gui/common/GroupFlagsWidget.h +++ b/retroshare-gui/src/gui/common/GroupFlagsWidget.h @@ -55,7 +55,7 @@ class GroupFlagsWidget: public QWidget QPushButton *_buttons[4] ; QLayout *_layout ; - QIcon *_icons[6] ; + QIcon _icons[6] ; FileStorageFlags _flags[4] ; static QString _tooltips_on[4] ; diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index db9b487b4..aa9b76023 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -21,6 +21,7 @@ #include "GroupTreeWidget.h" #include "ui_GroupTreeWidget.h" +#include "gui/common/FilesDefs.h" #include "retroshare/rsgxsflags.h" #include "PopularityDefs.h" @@ -250,11 +251,11 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton) displayMenu = new QMenu(); QActionGroup *actionGroupAsc = new QActionGroup(displayMenu); - actionSortDescending = displayMenu->addAction(QIcon(":/images/sort_decrease.png"), tr("Sort Descending Order"), this, SLOT(sort())); + actionSortDescending = displayMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/sort_decrease.png"), tr("Sort Descending Order"), this, SLOT(sort())); actionSortDescending->setCheckable(true); actionSortDescending->setActionGroup(actionGroupAsc); - actionSortAscending = displayMenu->addAction(QIcon(":/images/sort_incr.png"), tr("Sort Ascending Order"), this, SLOT(sort())); + actionSortAscending = displayMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/sort_incr.png"), tr("Sort Ascending Order"), this, SLOT(sort())); actionSortAscending->setCheckable(true); actionSortAscending->setActionGroup(actionGroupAsc); diff --git a/retroshare-gui/src/gui/common/LineEditClear.cpp b/retroshare-gui/src/gui/common/LineEditClear.cpp index 05bdca90b..b439aaa07 100644 --- a/retroshare-gui/src/gui/common/LineEditClear.cpp +++ b/retroshare-gui/src/gui/common/LineEditClear.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "LineEditClear.h" #include @@ -124,9 +125,8 @@ void LineEditClear::showFilterIcon() mFilterButton = new QToolButton(this); mFilterButton->setFixedSize(16, 16); - QPixmap filterPixmap(IMAGE_FILTER); - mFilterButton->setIcon(QIcon(filterPixmap)); - mFilterButton->setIconSize(filterPixmap.size()); + mFilterButton->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_FILTER)); + //mFilterButton->setIconSize(filterPixmap.size()); mFilterButton->setCursor(Qt::ArrowCursor); mFilterButton->setStyleSheet("QToolButton { border: none; padding: 0px; }" "QToolButton[popupMode=\"2\"] { padding-right: 10px; }" @@ -224,7 +224,7 @@ void LineEditClear::activateAction(QAction *action) QIcon icon = action->icon(); if (icon.isNull()) { - icon = QIcon(IMAGE_FILTER); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_FILTER); } mFilterButton->setIcon(icon); diff --git a/retroshare-gui/src/gui/common/MimeTextEdit.cpp b/retroshare-gui/src/gui/common/MimeTextEdit.cpp index cac02dc3e..b24a65879 100644 --- a/retroshare-gui/src/gui/common/MimeTextEdit.cpp +++ b/retroshare-gui/src/gui/common/MimeTextEdit.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -250,8 +251,8 @@ void MimeTextEdit::contextMenuEvent(QContextMenuEvent *e) QAction *spoilerAction = contextMenu->addAction(tr("Spoiler"), this, SLOT(spoiler())); spoilerAction->setToolTip(tr("Select text to hide, then push this button")); contextMenu->addSeparator(); - QAction *pasteLinkAction = contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); - contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink())); + QAction *pasteLinkAction = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink())); if (RSLinkClipboard::empty()) { pasteLinkAction->setDisabled(true); diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 9d9908642..2dd216383 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -32,6 +32,7 @@ #include "GroupDefs.h" #include "gui/chat/ChatDialog.h" #include "gui/common/AvatarDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/connect/ConfCertDialog.h" #include "gui/connect/PGPKeyDialog.h" @@ -577,20 +578,20 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() bool standard = group_info.flag & RS_GROUP_FLAG_STANDARD; #ifdef RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgGroup())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to whole group"), this, SLOT(msgGroup())); contextMenu.addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Group"), this, SLOT(editGroup())); - QAction *action = contextMenu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); + QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); action->setDisabled(standard); } break; case RsFriendListModel::ENTRY_TYPE_PROFILE: { - contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile())); - contextMenu.addAction(QIcon(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Profile details"), this, SLOT(configureProfile())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENYFRIEND), tr("Deny connections"), this, SLOT(removeProfile())); RsFriendListModel::RsProfileDetails details; mModel->getProfileData(index,details); @@ -636,8 +637,8 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() } } - QMenu *groupsMenu = contextMenu.addMenu(QIcon(IMAGE_GROUP16), tr("Groups")); - groupsMenu->addAction(QIcon(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); + QMenu *groupsMenu = contextMenu.addMenu(FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16), tr("Groups")); + groupsMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Create new group"), this, SLOT(createNewGroup())); if (addToGroupMenu || moveToGroupMenu || foundGroup) { if (addToGroupMenu) { @@ -674,26 +675,26 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() case RsFriendListModel::ENTRY_TYPE_NODE: { #ifdef RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode())); - contextMenu.addAction(QIcon(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CHAT), tr("Chat"), this, SLOT(chatNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MSG), tr("Send message to this node"), this, SLOT(msgNode())); contextMenu.addSeparator(); #endif // RS_DIRECT_CHAT - contextMenu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Node details"), this, SLOT(configureNode())); if (type == RsFriendListModel::ENTRY_TYPE_PROFILE || type == RsFriendListModel::ENTRY_TYPE_NODE) - contextMenu.addAction(QIcon(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORTFRIEND), tr("Recommend this node to..."), this, SLOT(recommendNode())); RsFriendListModel::RsNodeDetails details; mModel->getNodeData(index,details); if(!rsPeers->isHiddenNode(rsPeers->getOwnId()) || rsPeers->isHiddenNode( details.id )) - contextMenu.addAction(QIcon(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CONNECT), tr("Attempt to connect"), this, SLOT(connectNode())); - contextMenu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy certificate link"), this, SLOT(copyFullCertificate())); //this is a SSL key - contextMenu.addAction(QIcon(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_REMOVEFRIEND), tr("Remove Friend Node"), this, SLOT(removeNode())); } } @@ -702,12 +703,12 @@ void NewFriendList::peerTreeWidgetCustomPopupMenu() contextMenu.addSeparator(); - QAction *action = contextMenu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); + QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_PASTELINK), tr("Paste certificate link"), this, SLOT(pastePerson())); if (RSLinkClipboard::empty(RetroShareLink::TYPE_CERTIFICATE)) action->setDisabled(true); - contextMenu.addAction(QIcon(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); - contextMenu.addAction(QIcon(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPAND), tr("Expand all"), ui->peerTreeWidget, SLOT(expandAll())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COLLAPSE), tr("Collapse all"), ui->peerTreeWidget, SLOT(collapseAll())); contextMenu.addSeparator(); diff --git a/retroshare-gui/src/gui/common/PopularityDefs.cpp b/retroshare-gui/src/gui/common/PopularityDefs.cpp index 096cdc1cf..d027c4248 100644 --- a/retroshare-gui/src/gui/common/PopularityDefs.cpp +++ b/retroshare-gui/src/gui/common/PopularityDefs.cpp @@ -20,22 +20,23 @@ #include +#include "FilesDefs.h" #include "PopularityDefs.h" QIcon PopularityDefs::icon(int popularity) { if (popularity <= 1) - return QIcon(":/images/hot_0.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_0.png"); else if (popularity <= 2) /* 1-1 */ - return QIcon(":/images/hot_1.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_1.png"); else if (popularity <= 5) /* 2-2 */ - return QIcon(":/images/hot_2.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_2.png"); else if (popularity <= 10) /* 3-5 */ - return QIcon(":/images/hot_3.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_3.png"); else if (popularity <= 20) /* 6-10 */ - return QIcon(":/images/hot_4.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_4.png"); else /* >10 */ - return QIcon(":/images/hot_5.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/hot_5.png"); } QString PopularityDefs::tooltip(int popularity) diff --git a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp index b9a84b7a1..89976f6e8 100644 --- a/retroshare-gui/src/gui/common/RsCollectionDialog.cpp +++ b/retroshare-gui/src/gui/common/RsCollectionDialog.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "RsCollectionDialog.h" #include "RsCollection.h" @@ -254,7 +255,7 @@ void RsCollectionDialog::openDestinationDirectoryMenu() contextMnu.addAction(QString::fromUtf8((*it).filename.c_str()), this, SLOT(setDestinationDirectory()))->setData(QString::fromUtf8( (*it).filename.c_str() ) ) ; } - contextMnu.addAction( QIcon(IMAGE_SEARCH),tr("Specify..."),this,SLOT(chooseDestinationDirectory())); + contextMnu.addAction( FilesDefs::getIconFromQtResourcePath(IMAGE_SEARCH),tr("Specify..."),this,SLOT(chooseDestinationDirectory())); contextMnu.exec(QCursor::pos()) ; } diff --git a/retroshare-gui/src/gui/common/SubscribeToolButton.cpp b/retroshare-gui/src/gui/common/SubscribeToolButton.cpp index 4bb0147e6..4015e641c 100644 --- a/retroshare-gui/src/gui/common/SubscribeToolButton.cpp +++ b/retroshare-gui/src/gui/common/SubscribeToolButton.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include "SubscribeToolButton.h" @@ -64,14 +65,14 @@ void SubscribeToolButton::updateUi() #else setPopupMode(QToolButton::InstantPopup); #endif - //setIcon(QIcon(":/images/accepted16.png")); + //setIcon(FilesDefs::getIconFromQtResourcePath(":/images/accepted16.png")); setText(tr("Subscribed")); if(mMenu != NULL) // that's because setMenu does not give away memory ownership delete mMenu ; mMenu = new QMenu; - mMenu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate())); + mMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate())); if (!mSubscribedActions.empty()) { mMenu->addSeparator(); @@ -86,7 +87,7 @@ void SubscribeToolButton::updateUi() } else { setPopupMode(QToolButton::DelayedPopup); setMenu(NULL); - //setIcon(QIcon(":/images/RSS_004_32.png")); + //setIcon(FilesDefs::getIconFromQtResourcePath(":/images/RSS_004_32.png")); setText(tr("Subscribe")); #ifndef USE_MENUBUTTONPOPUP diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 4ad6315b9..c225d3eac 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -33,6 +33,7 @@ #include #endif +#include "gui/common/FilesDefs.h" #include "gui/settings/rsharesettings.h" #include "util/misc.h" #include "ConnectFriendWizard.h" @@ -145,11 +146,11 @@ ConnectFriendWizard::ConnectFriendWizard(QWidget *parent) : switch (rsFiles->filePermDirectDL()) { case RS_FILE_PERM_DIRECT_DL_YES: - ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui->_direct_transfer_CB_2->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes."))); break ; case RS_FILE_PERM_DIRECT_DL_NO: - ui->_direct_transfer_CB_2->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui->_direct_transfer_CB_2->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui->_direct_transfer_CB_2->setToolTip(ui->_direct_transfer_CB_2->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No."))); break ; diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index d27e779fd..5dde6822c 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "PGPKeyDialog.h" #include @@ -156,11 +157,11 @@ void PGPKeyDialog::load() switch (rsFiles->filePermDirectDL()) { case RS_FILE_PERM_DIRECT_DL_YES: - ui._direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui._direct_transfer_CB->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui._direct_transfer_CB->setToolTip(ui._direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to Yes."))); break ; case RS_FILE_PERM_DIRECT_DL_NO: - ui._direct_transfer_CB->setIcon(QIcon(":/icons/warning_yellow_128.png")); + ui._direct_transfer_CB->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); ui._direct_transfer_CB->setToolTip(ui._direct_transfer_CB->toolTip().append(tr("\nWarning: In your File-Transfer option, you select allow direct download to No."))); break ; diff --git a/retroshare-gui/src/gui/elastic/elnode.cpp b/retroshare-gui/src/gui/elastic/elnode.cpp index 0fef49cba..86bb4e31e 100644 --- a/retroshare-gui/src/gui/elastic/elnode.cpp +++ b/retroshare-gui/src/gui/elastic/elnode.cpp @@ -20,6 +20,7 @@ // This code is inspired from http://doc.qt.io/qt-5/qtwidgets-graphicsview-elasticnodes-node-cpp.html +#include "gui/common/FilesDefs.h" #include #include @@ -366,11 +367,11 @@ void Node::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QMenu contextMnu ; if(_type == GraphWidget::ELASTIC_NODE_TYPE_FRIEND) - contextMnu.addAction(QIcon(IMAGE_DENIED), QObject::tr( "Deny friend" ), this, SLOT(denyFriend()) ); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DENIED), QObject::tr( "Deny friend" ), this, SLOT(denyFriend()) ); else if(_type != GraphWidget::ELASTIC_NODE_TYPE_OWN) - contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Make friend" ), this, SLOT(makeFriend()) ); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MAKEFRIEND), QObject::tr( "Make friend" ), this, SLOT(makeFriend()) ); - contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Peer details" ), this, SLOT(peerDetails()) ); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MAKEFRIEND), QObject::tr( "Peer details" ), this, SLOT(peerDetails()) ); contextMnu.exec(event->screenPos()); } diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp index e1c9a028f..8f53b5fe4 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp @@ -24,6 +24,7 @@ #include "FeedHolder.h" #include "util/qtthreadsutils.h" +#include "gui/common/FilesDefs.h" #include "gui/NewsFeed.h" #include "gui/RetroShareLink.h" @@ -187,13 +188,13 @@ void GxsChannelGroupItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 4a559e001..5df1a8906 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -22,6 +22,7 @@ #include "ui_GxsForumGroupItem.h" #include "gui/NewsFeed.h" +#include "gui/common/FilesDefs.h" #include "FeedHolder.h" #include "gui/RetroShareLink.h" #include "util/qtthreadsutils.h" @@ -251,13 +252,13 @@ void GxsForumGroupItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index f6afc8cdd..4d4bdd661 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -28,6 +28,7 @@ #include "FeedHolder.h" #include "gui/RetroShareLink.h" +#include "gui/common/FilesDefs.h" #include "gui/gxs/GxsIdDetails.h" #include "util/HandleRichText.h" #include "util/qtthreadsutils.h" @@ -421,7 +422,7 @@ void GxsForumMsgItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); if (!mParentMessage.mMeta.mMsgId.isNull()) { @@ -434,7 +435,7 @@ void GxsForumMsgItem::doExpand(bool open) { ui->expandFrame->hide(); ui->parentFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 181774a00..a25e97873 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -29,6 +29,7 @@ #include "util/HandleRichText.h" #include "util/DateTime.h" #include "gui/common/AvatarDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/notifyqt.h" #include @@ -231,7 +232,7 @@ void MsgItem::doExpand(bool open) if (open) { expandFrame->show(); - expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); expandButton->setToolTip(tr("Hide")); mCloseOnRead = false; @@ -241,7 +242,7 @@ void MsgItem::doExpand(bool open) else { expandFrame->hide(); - expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp b/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp index e71c166f2..65a377edf 100644 --- a/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp +++ b/retroshare-gui/src/gui/feeds/NewsFeedUserNotify.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "NewsFeedUserNotify.h" #include "gui/NewsFeed.h" @@ -37,7 +38,7 @@ void NewsFeedUserNotify::newsFeedChanged(int count) QIcon NewsFeedUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/newsfeed-notify.png") : QIcon(":/icons/png/newsfeed.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/newsfeed-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/newsfeed.png"); } unsigned int NewsFeedUserNotify::getNewCount() diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 2a6f0b19d..a03572f61 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -26,6 +26,7 @@ #include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" #include "gui/common/StatusDefs.h" +#include "gui/common/FilesDefs.h" #include "gui/common/AvatarDefs.h" #include "util/DateTime.h" @@ -243,13 +244,13 @@ void PeerItem::doExpand(bool open) if (open) { expandFrame->show(); - expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); expandButton->setToolTip(tr("Hide")); } else { expandFrame->hide(); - expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp index 6b39566aa..90d766bc2 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp @@ -25,6 +25,7 @@ #include "util/qtthreadsutils.h" #include "gui/RetroShareLink.h" #include "gui/gxs/GxsIdDetails.h" +#include "gui/common/FilesDefs.h" /**** * #define DEBUG_ITEM 1 @@ -204,13 +205,13 @@ void PostedGroupItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp index 590bd0588..6e543108d 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.cpp @@ -29,6 +29,7 @@ #include "util/DateTime.h" #include "gui/common/PeerDefs.h" #include "gui/common/RsBanListDefs.h" +#include "gui/common/FilesDefs.h" #include #include @@ -199,13 +200,13 @@ void SecurityIpItem::doExpand(bool open) if (open) { ui->expandFrame->show(); - ui->expandButton->setIcon(QIcon(":/icons/png/up-arrow.png")); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/up-arrow.png")); ui->expandButton->setToolTip(tr("Hide")); } else { ui->expandFrame->hide(); - ui->expandButton->setIcon(QIcon(":/icons/png/down-arrow.png")); + ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/down-arrow.png")); ui->expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index aedfd4e6c..b2bbc2cf3 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -29,6 +29,7 @@ #include "gui/common/StatusDefs.h" #include "gui/connect/ConfCertDialog.h" #include "gui/connect/PGPKeyDialog.h" +#include "gui/common/FilesDefs.h" #include "gui/connect/ConnectFriendWizard.h" #include "gui/common/AvatarDefs.h" #include "util/DateTime.h" @@ -295,13 +296,13 @@ void SecurityItem::doExpand(bool open) if (open) { expandFrame->show(); - expandButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); expandButton->setToolTip(tr("Hide")); } else { expandFrame->hide(); - expandButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); expandButton->setToolTip(tr("Expand")); } diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index a1f824e9a..dfdd9bd04 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -211,14 +211,14 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/) contextMnu.addSeparator(); QMenu *rep_menu = contextMnu.addMenu(tr("Reputation")); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Show Reputation"), this, SLOT(showReputation())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Show Reputation"), this, SLOT(showReputation())); contextMnu.addSeparator(); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Interesting User"), this, SLOT(markInteresting())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Interesting User"), this, SLOT(markInteresting())); contextMnu.addSeparator(); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Mark Spammy"), this, SLOT(markSpammer())); - action = rep_menu->addAction(QIcon(IMAGE_MESSAGE), tr("Ban User"), this, SLOT(banUser())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Mark Spammy"), this, SLOT(markSpammer())); + action = rep_menu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("Ban User"), this, SLOT(banUser())); */ } diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index b7f3fcf20..1021a3937 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -151,16 +151,16 @@ void GxsGroupFrameDialog::initUi() /* Initialize group tree */ QToolButton *newGroupButton = new QToolButton(this); - newGroupButton->setIcon(QIcon(icon(ICON_NEW))); + newGroupButton->setIcon(FilesDefs::getIconFromQtResourcePath(icon(ICON_NEW))); newGroupButton->setToolTip(text(TEXT_NEW)); connect(newGroupButton, SIGNAL(clicked()), this, SLOT(newGroup())); ui->groupTreeWidget->addToolButton(newGroupButton); /* Create group tree */ - mYourGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_YOUR_GROUP), QIcon(icon(ICON_YOUR_GROUP)), true); - mSubscribedGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_SUBSCRIBED_GROUP), QIcon(icon(ICON_SUBSCRIBED_GROUP)), true); - mPopularGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_POPULAR_GROUP), QIcon(icon(ICON_POPULAR_GROUP)), false); - mOtherGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_OTHER_GROUP), QIcon(icon(ICON_OTHER_GROUP)), false); + mYourGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_YOUR_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_YOUR_GROUP)), true); + mSubscribedGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_SUBSCRIBED_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_SUBSCRIBED_GROUP)), true); + mPopularGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_POPULAR_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_POPULAR_GROUP)), false); + mOtherGroups = ui->groupTreeWidget->addCategoryItem(text(TEXT_OTHER_GROUP), FilesDefs::getIconFromQtResourcePath(icon(ICON_OTHER_GROUP)), false); if (text(TEXT_TODO).isEmpty()) { ui->todoPushButton->hide(); @@ -410,8 +410,8 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(IMAGE_DELETE), tr("Remove this search"), this, SLOT(removeCurrentSearch()))->setData(search_request_id); - contextMnu.addAction(QIcon(IMAGE_DELETE), tr("Remove all searches"), this, SLOT(removeAllSearches())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DELETE), tr("Remove this search"), this, SLOT(removeCurrentSearch()))->setData(search_request_id); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DELETE), tr("Remove all searches"), this, SLOT(removeAllSearches())); contextMnu.exec(QCursor::pos()); return ; } @@ -424,7 +424,7 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(IMAGE_RETRIEVE), tr("Request data"), this, SLOT(distantRequestGroupData()))->setData(group_id_s); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_RETRIEVE), tr("Request data"), this, SLOT(distantRequestGroupData()))->setData(group_id_s); contextMnu.exec(QCursor::pos()); return ; } @@ -442,27 +442,27 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) QMenu contextMnu(this); QAction *action; - action = contextMnu.addAction(QIcon(IMAGE_TABNEW), tr("Open in new tab"), this, SLOT(openInNewTab())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_TABNEW), tr("Open in new tab"), this, SLOT(openInNewTab())); if(mGroupId.isNull()) // dont enable the open in tab if a tab is already here action->setEnabled(false); if (isSubscribed) { - action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeGroup())); action->setEnabled (!mGroupId.isNull() && IS_GROUP_SUBSCRIBED(subscribeFlags)); } else { - action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeGroup())); action->setDisabled (mGroupId.isNull() || IS_GROUP_SUBSCRIBED(subscribeFlags)); } contextMnu.addSeparator(); - contextMnu.addAction(QIcon(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(icon(ICON_NEW)), text(TEXT_NEW), this, SLOT(newGroup())); - action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_INFO), tr("Show Details"), this, SLOT(showGroupDetails())); action->setEnabled (!mGroupId.isNull()); - action = contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT), tr("Edit Details"), this, SLOT(editGroupDetails())); action->setEnabled (!mGroupId.isNull() && isAdmin); uint32_t current_store_time = checkDelay(mInterface->getStoragePeriod(mGroupId))/86400 ; @@ -472,39 +472,39 @@ void GxsGroupFrameDialog::groupTreeCustomPopupMenu(QPoint point) QAction *actnn = NULL; QMenu *ctxMenu2 = contextMnu.addMenu(tr("Synchronise posts of last...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_sync_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_sync_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_sync_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_sync_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_sync_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_sync_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setSyncPostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_sync_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} ctxMenu2 = contextMnu.addMenu(tr("Store posts for at most...")) ; - actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} - actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(QIcon(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 5 days" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 5)) ; if(current_store_time == 5) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 2 weeks" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 15)) ; if(current_store_time == 15) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 month" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 30)) ; if(current_store_time == 30) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 3 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 90)) ; if(current_store_time == 90) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 6 months" ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(180)) ; if(current_store_time ==180) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" 1 year " ),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant(365)) ; if(current_store_time ==365) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} + actnn = ctxMenu2->addAction(tr(" Indefinitly"),this,SLOT(setStorePostsDelay())) ; actnn->setData(QVariant( 0)) ; if(current_store_time == 0) { actnn->setEnabled(false);actnn->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/start.png"));} if (shareKeyType()) { - action = contextMnu.addAction(QIcon(IMAGE_SHARE), tr("Share publish permissions..."), this, SLOT(sharePublishKey())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_SHARE), tr("Share publish permissions..."), this, SLOT(sharePublishKey())); action->setEnabled(!mGroupId.isNull() && isPublisher); } if (getLinkType() != RetroShareLink::TYPE_UNKNOWN) { - action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyGroupLink())); action->setEnabled(!mGroupId.isNull()); } contextMnu.addSeparator(); - action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsRead())); action->setEnabled (!mGroupId.isNull() && isSubscribed); - action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnread())); action->setEnabled (!mGroupId.isNull() && isSubscribed); /* Add special actions */ @@ -739,7 +739,7 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const QVectorcommentLoad(grpId, msgv,most_recent_msgId); int index = ui->messageTabWidget->addTab(commentDialog, comments); - ui->messageTabWidget->setTabIcon(index, QIcon(IMAGE_COMMENT)); + ui->messageTabWidget->setTabIcon(index, FilesDefs::getIconFromQtResourcePath(IMAGE_COMMENT)); } ui->messageTabWidget->setCurrentWidget(commentDialog); @@ -956,12 +956,12 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData * #if TOGXS if (groupInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) { groupItemInfo.name += " (" + tr("AUTHD") + ")"; - groupItemInfo.icon = QIcon(IMAGE_GROUPAUTHD); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(IMAGE_GROUPAUTHD); } else #endif { - groupItemInfo.icon = QIcon(icon(ICON_DEFAULT)); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(icon(ICON_DEFAULT)); } } @@ -1209,7 +1209,7 @@ void GxsGroupFrameDialog::searchNetwork(const QString& search_string) if(request_id == 0) return ; - mSearchGroupsItems[request_id] = ui->groupTreeWidget->addSearchItem(tr("Search for")+ " \"" + search_string + "\"",(uint32_t)request_id,QIcon(icon(ICON_SEARCH))); + mSearchGroupsItems[request_id] = ui->groupTreeWidget->addSearchItem(tr("Search for")+ " \"" + search_string + "\"",(uint32_t)request_id,FilesDefs::getIconFromQtResourcePath(icon(ICON_SEARCH))); } void GxsGroupFrameDialog::distantRequestGroupData() diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 2db5d8534..6235c025f 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -22,6 +22,7 @@ #include "GxsIdDetails.h" #include "RsGxsUpdateBroadcastBase.h" #include "gui/Identity/IdEditDialog.h" +#include "gui/common/FilesDefs.h" #include "util/misc.h" #include @@ -162,7 +163,7 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail break; case GXS_ID_DETAILS_TYPE_BANNED: - icons.push_back(QIcon(BANNED_ICON)) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(BANNED_ICON)) ; break; } @@ -285,7 +286,7 @@ void GxsIdChooser::loadPrivateIds() QString str = tr("Create new Identity"); QString id = ""; - addItem(QIcon(":/icons/png/add-identity.png"), str, id); + addItem(FilesDefs::getIconFromQtResourcePath(":/icons/png/add-identity.png"), str, id); setItemData(count() - 1, QString("%1_%2").arg(TYPE_CREATE_ID).arg(str), ROLE_SORT); setItemData(count() - 1, TYPE_CREATE_ID, ROLE_TYPE); diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index 701a9153d..a7d050dd5 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -21,6 +21,7 @@ #include "GxsIdDetails.h" #include "gui/common/AvatarDialog.h" +#include "gui/common/FilesDefs.h" #include "retroshare-gui/RsAutoUpdatePage.h" #include @@ -375,10 +376,10 @@ static bool findTagIcon(int tag_class, int /*tag_type*/, QIcon &icon) { default: case 0: - icon = QIcon(IMAGE_DEV_AMBASSADOR); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_DEV_AMBASSADOR); break; case 1: - icon = QIcon(IMAGE_DEV_CONTRIBUTOR); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_DEV_CONTRIBUTOR); break; } return true; @@ -974,7 +975,7 @@ QString GxsIdDetails::getNameForType(GxsIdDetailsType type, const RsIdentityDeta QIcon GxsIdDetails::getLoadingIcon(const RsGxsId &/*id*/) { - return QIcon(IMAGE_LOADING); + return FilesDefs::getIconFromQtResourcePath(IMAGE_LOADING); } bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QList &icons, QString& comment,uint32_t icon_types) @@ -1005,9 +1006,9 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi // Cyril: I disabled these three which I believe to have been put for testing purposes. // -// icons.push_back(QIcon(IMAGE_ANON)); -// icons.push_back(QIcon(IMAGE_ANON)); -// icons.push_back(QIcon(IMAGE_ANON)); +// icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_ANON)); +// icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_ANON)); +// icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_ANON)); // std::cerr << "GxsIdTreeWidget::MakeIdDesc() ID Ok. Comment: " << comment.toStdString() ; // std::cerr << std::endl; @@ -1083,20 +1084,20 @@ QIcon GxsIdDetails::getReputationIcon( RsReputationLevel icon_index, uint32_t min_reputation ) { if( static_cast(icon_index) >= min_reputation ) - return QIcon(REPUTATION_VOID); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_VOID); switch(icon_index) { case RsReputationLevel::LOCALLY_NEGATIVE: - return QIcon(REPUTATION_LOCALLY_NEGATIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_LOCALLY_NEGATIVE_ICON); case RsReputationLevel::LOCALLY_POSITIVE: - return QIcon(REPUTATION_LOCALLY_POSITIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_LOCALLY_POSITIVE_ICON); case RsReputationLevel::REMOTELY_POSITIVE: - return QIcon(REPUTATION_REMOTELY_POSITIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_REMOTELY_POSITIVE_ICON); case RsReputationLevel::REMOTELY_NEGATIVE: - return QIcon(REPUTATION_REMOTELY_NEGATIVE_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_REMOTELY_NEGATIVE_ICON); case RsReputationLevel::NEUTRAL: - return QIcon(REPUTATION_NEUTRAL_ICON); + return FilesDefs::getIconFromQtResourcePath(REPUTATION_NEUTRAL_ICON); default: std::cerr << "Asked for unidentified icon index " << static_cast(icon_index) << std::endl; @@ -1112,7 +1113,7 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icon RsReputationLevel::LOCALLY_NEGATIVE ) { icons.clear() ; - icons.push_back(QIcon(IMAGE_BANNED)) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath(IMAGE_BANNED)) ; return ; } @@ -1141,12 +1142,12 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList &icon if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) { if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN) - baseIcon = QIcon(IMAGE_PGPKNOWN); + baseIcon = FilesDefs::getIconFromQtResourcePath(IMAGE_PGPKNOWN); else - baseIcon = QIcon(IMAGE_PGPUNKNOWN); + baseIcon = FilesDefs::getIconFromQtResourcePath(IMAGE_PGPUNKNOWN); } else - baseIcon = QIcon(IMAGE_ANON); + baseIcon = FilesDefs::getIconFromQtResourcePath(IMAGE_ANON); icons.push_back(baseIcon); } diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index 413aef616..aa9201e95 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -67,7 +67,7 @@ static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIde break; case GXS_ID_DETAILS_TYPE_BANNED: - icons.push_back(QIcon("BANNED_IMAGE")) ; + icons.push_back(FilesDefs::getIconFromQtResourcePath("BANNED_IMAGE")) ; break ; } diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index ef1a6271e..177289f09 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -122,9 +122,9 @@ void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) QAction *action ; if(n_file > 1) - action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink())); else - action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); action->setDisabled(n_file < 1) ; contextMnu.exec(QCursor::pos()); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index 5e1c40fe4..a70fdf395 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -251,8 +251,8 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF if (isSubscribed) { - QAction *action = autoDownload ? (new QAction(QIcon(":/images/redled.png"), tr("Disable Auto-Download"), this)) - : (new QAction(QIcon(":/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); @@ -263,7 +263,7 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF QMenu *mnu = new QMenu(tr("Set download directory")) ; if(dl_directory.empty()) - mnu->addAction(QIcon(":/images/start.png"),tr("[Default directory]"), this, SLOT(setDefaultDirectory())) ; + mnu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),tr("[Default directory]"), this, SLOT(setDefaultDirectory())) ; else mnu->addAction(tr("[Default directory]"), this, SLOT(setDefaultDirectory())) ; @@ -277,7 +277,7 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF if(dl_directory == it->filename) { - action = new QAction(QIcon(":/images/start.png"),QString::fromUtf8(it->filename.c_str()),NULL) ; + action = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),QString::fromUtf8(it->filename.c_str()),NULL) ; found = true ; } else @@ -291,7 +291,7 @@ void GxsChannelDialog::groupTreeCustomActions(RsGxsGroupId grpId, int subscribeF if(!found && !dl_directory.empty()) { - QAction *action = new QAction(QIcon(":/images/start.png"),QString::fromUtf8(dl_directory.c_str()),NULL) ; + QAction *action = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/start.png"),QString::fromUtf8(dl_directory.c_str()),NULL) ; connect(action,SIGNAL(triggered()),this,SLOT(setDownloadDirectory())) ; action->setData(QString::fromUtf8(dl_directory.c_str())) ; @@ -391,7 +391,7 @@ void GxsChannelDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *gro groupItemInfo.icon = image; } else - groupItemInfo.icon = QIcon(":icons/png/channel.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/channel.png"); groupItemInfo.description = QString::fromUtf8(channelGroupData->mDescription.c_str()); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index bbbb26a42..a393b1d38 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -220,11 +220,11 @@ void GxsChannelPostsWidget::groupNameChanged(const QString &name) QIcon GxsChannelPostsWidget::groupIcon() { if (mStateHelper->isLoading(mTokenTypeGroupData) || mStateHelper->isLoading(mTokenTypeAllPosts)) { - return QIcon(":/images/kalarm.png"); + return FilesDefs::getIconFromQtResourcePath(":/images/kalarm.png"); } // if (mNewCount) { -// return QIcon(":/images/message-state-new.png"); +// return FilesDefs::getIconFromQtResourcePath(":/images/message-state-new.png"); // } return QIcon(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index fd9c591ca..04777fa8c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -775,7 +775,7 @@ void GxsForumThreadWidget::togglethreadview_internal() ui->expandButton->setToolTip(tr("Hide")); // } else { // ui->postText->setVisible(false); -// ui->expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); +// ui->expandButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/images/edit_add24.png"))); // ui->expandButton->setToolTip(tr("Expand")); // } } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index b0dcc0402..7ce84ea5c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -228,8 +228,8 @@ void GxsForumsDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *grou groupItemInfo.description = QString::fromUtf8(forumGroupData->mDescription.c_str()); if(IS_GROUP_ADMIN(groupData->mMeta.mSubscribeFlags)) - groupItemInfo.icon = QIcon(":icons/png/forums.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/forums.png"); else if ((IS_GROUP_PGP_AUTHED(groupData->mMeta.mSignFlags)) || (IS_GROUP_MESSAGE_TRACKING(groupData->mMeta.mSignFlags)) ) - groupItemInfo.icon = QIcon(":icons/png/forums-signed.png"); + groupItemInfo.icon = FilesDefs::getIconFromQtResourcePath(":icons/png/forums-signed.png"); } diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 92f4de457..db3083686 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -696,7 +697,7 @@ void MessageComposer::contextMenuFileList(QPoint) { QMenu contextMnu(this); - QAction *action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteRecommended())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteRecommended())); action->setDisabled(RSLinkClipboard::empty(RetroShareLink::TYPE_FILE)); contextMnu.exec(QCursor::pos()); @@ -805,7 +806,7 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status) { QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON); if (item) - item->setIcon(QIcon(StatusDefs::imageUser(status))); + item->setIcon(FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(status))); } } } @@ -1606,7 +1607,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType switch(dest_type) { case PEER_TYPE_GROUP: { - icon = QIcon(IMAGE_GROUP16); + icon = FilesDefs::getIconFromQtResourcePath(IMAGE_GROUP16); RsGroupInfo groupInfo; if (rsPeers->getGroupInfo(RsNodeGroupId(id), groupInfo)) { @@ -1652,7 +1653,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType // No check of return value. Non existing status info is handled as offline. rsStatus->getStatus(RsPeerId(id), peerStatusInfo); - icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status)); + icon = FilesDefs::getIconFromQtResourcePath(StatusDefs::imageUser(peerStatusInfo.status)); } break ; default: @@ -1928,7 +1929,7 @@ void MessageComposer::setupFileActions() connect(a, SIGNAL(triggered()), this, SLOT(filePrint())); menu->addAction(a); - /*a = new QAction(QIcon(":/images/textedit/fileprint.png"), tr("Print Preview..."), this); + /*a = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/fileprint.png"), tr("Print Preview..."), this); connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview())); menu->addAction(a);*/ @@ -2021,7 +2022,7 @@ void MessageComposer::setupContactActions() connect(mActionAddBCC, SIGNAL(triggered(bool)), this, SLOT(addBcc())); mActionAddRecommend = new QAction(tr("Add as Recommend"), this); connect(mActionAddRecommend, SIGNAL(triggered(bool)), this, SLOT(addRecommend())); - mActionContactDetails = new QAction(QIcon(IMAGE_FRIENDINFO), tr("Details"), this); + mActionContactDetails = new QAction(FilesDefs::getIconFromQtResourcePath(IMAGE_FRIENDINFO), tr("Details"), this); connect(mActionContactDetails, SIGNAL(triggered(bool)), this, SLOT(contactDetails())); ui.friendSelectionWidget->addContextMenuAction(mActionAddTo); @@ -2435,9 +2436,9 @@ void MessageComposer::on_contactsdockWidget_visibilityChanged(bool visible) void MessageComposer::updatecontactsviewicons() { if(!ui.contactsdockWidget->isVisible()){ - ui.actionContactsView->setIcon(QIcon(":/icons/mail/contacts.png")); + ui.actionContactsView->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/mail/contacts.png")); }else{ - ui.actionContactsView->setIcon(QIcon(":/icons/mail/contacts.png")); + ui.actionContactsView->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/mail/contacts.png")); } } diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index fa586f1c8..4144867c6 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "MessageUserNotify.h" #include "gui/notifyqt.h" #include "gui/MainWindow.h" @@ -40,12 +41,12 @@ bool MessageUserNotify::hasSetting(QString *name, QString *group) QIcon MessageUserNotify::getIcon() { - return QIcon(":/icons/png/messages.png"); + return FilesDefs::getIconFromQtResourcePath(":/icons/png/messages.png"); } QIcon MessageUserNotify::getMainIcon(bool hasNew) { - return hasNew ? QIcon(":/icons/png/messages-notify.png") : QIcon(":/icons/png/messages.png"); + return hasNew ? FilesDefs::getIconFromQtResourcePath(":/icons/png/messages-notify.png") : FilesDefs::getIconFromQtResourcePath(":/icons/png/messages.png"); } unsigned int MessageUserNotify::getNewCount() diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 086986230..d3f3af131 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -315,8 +315,8 @@ void MessageWidget::msgfilelistWidgetCostumPopupMenu( QPoint /*point*/ ) { QMenu contextMnu(this); - contextMnu.addAction(QIcon(IMAGE_DOWNLOAD), tr("Download"), this, SLOT(getcurrentrecommended())); - contextMnu.addAction(QIcon(IMAGE_DOWNLOADALL), tr("Download all"), this, SLOT(getallrecommended())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOAD), tr("Download"), this, SLOT(getcurrentrecommended())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOADALL), tr("Download all"), this, SLOT(getallrecommended())); contextMnu.exec(QCursor::pos()); } @@ -328,10 +328,10 @@ void MessageWidget::togglefileview(bool noUpdate/*=false*/) */ if (ui.expandFilesButton->isChecked()) { - ui.expandFilesButton->setIcon(QIcon(QString(":/icons/png/down-arrow.png"))); + ui.expandFilesButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/down-arrow.png"))); ui.expandFilesButton->setToolTip(tr("Hide the attachment pane")); } else { - ui.expandFilesButton->setIcon(QIcon(QString(":/icons/png/up-arrow.png"))); + ui.expandFilesButton->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/up-arrow.png"))); ui.expandFilesButton->setToolTip(tr("Show the attachment pane")); } if (!noUpdate) diff --git a/retroshare-gui/src/gui/msgs/MessageWindow.cpp b/retroshare-gui/src/gui/msgs/MessageWindow.cpp index 17355143f..ad1067367 100644 --- a/retroshare-gui/src/gui/msgs/MessageWindow.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWindow.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "MessageWindow.h" #include "MessageWidget.h" #include "MessageComposer.h" @@ -180,12 +181,12 @@ void MessageWindow::setupFileActions() menuBar()->addMenu(menu); actionSaveAs = menu->addAction(tr("Save &As File")); - actionPrint = menu->addAction(QIcon(":/images/textedit/fileprint.png"), tr("&Print...")); + actionPrint = menu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/fileprint.png"), tr("&Print...")); actionPrint->setShortcut(QKeySequence::Print); - actionPrintPreview = menu->addAction(QIcon(":/images/textedit/fileprint.png"), tr("Print Preview...")); + actionPrintPreview = menu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/fileprint.png"), tr("Print Preview...")); -// a = new QAction(QIcon(":/images/textedit/exportpdf.png"), tr("&Export PDF..."), this); +// a = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/textedit/exportpdf.png"), tr("&Export PDF..."), this); // a->setShortcut(Qt::CTRL + Qt::Key_D); // connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf())); // menu->addAction(a); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 40b61739a..acb19d900 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -422,7 +422,7 @@ void MessagesDialog::fillQuickView() // add static items item = new QListWidgetItem(tr("Starred"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_STAR_ON)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_STAR_ON)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_STARRED); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -432,7 +432,7 @@ void MessagesDialog::fillQuickView() } item = new QListWidgetItem(tr("System"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_NOTFICATION)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_NOTFICATION)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_SYSTEM); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -442,7 +442,7 @@ void MessagesDialog::fillQuickView() } item = new QListWidgetItem(tr("Spam"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_SPAM_ON)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_SPAM_ON)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_SPAM); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -452,7 +452,7 @@ void MessagesDialog::fillQuickView() } item = new QListWidgetItem(tr("Attachment"), ui.quickViewWidget); - item->setIcon(QIcon(IMAGE_ATTACHMENT)); + item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_ATTACHMENT)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_ATTACHMENT); item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList @@ -584,13 +584,13 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) QMenu contextMnu( this ); - QAction *action = contextMnu.addAction(QIcon(":/images/view_split_top_bottom.png"), tr("Open in a new window"), this, SLOT(openAsWindow())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/view_split_top_bottom.png"), tr("Open in a new window"), this, SLOT(openAsWindow())); if (nCount != 1) { action->setDisabled(true); } - action = contextMnu.addAction(QIcon(":/images/tab-dock.png"), tr("Open in a new tab"), this, SLOT(openAsTab())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/tab-dock.png"), tr("Open in a new tab"), this, SLOT(openAsTab())); if (nCount != 1) { action->setDisabled(true); } @@ -608,12 +608,12 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) contextMnu.addSeparator(); - action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read"), this, SLOT(markAsRead())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail-read.png"), tr("Mark as read"), this, SLOT(markAsRead())); if (itemsUnread.isEmpty()) { action->setDisabled(true); } - action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark as unread"), this, SLOT(markAsUnread())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/message-mail.png"), tr("Mark as unread"), this, SLOT(markAsUnread())); if (itemsRead.isEmpty()) { action->setDisabled(true); @@ -647,7 +647,7 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) action->setDisabled(true); } - action = contextMnu.addAction(QIcon(IMAGE_MESSAGEREMOVE), (nCount > 1) ? tr("Remove Messages") : tr("Remove Message"), this, SLOT(removemessage())); + action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGEREMOVE), (nCount > 1) ? tr("Remove Messages") : tr("Remove Message"), this, SLOT(removemessage())); if (nCount == 0) { action->setDisabled(true); } @@ -674,11 +674,11 @@ void MessagesDialog::messageTreeWidgetCustomPopupMenu(QPoint /*point*/) { std::cerr << "Src ID = " << msgInfo.rsgxsid_srcId << std::endl; - contextMnu.addAction(QIcon(IMAGE_AUTHOR_INFO),tr("Show author in People"),this,SLOT(showAuthorInPeopleTab())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR_INFO),tr("Show author in People"),this,SLOT(showAuthorInPeopleTab())); contextMnu.addSeparator(); } - contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("New Message"), this, SLOT(newmessage())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_MESSAGE), tr("New Message"), this, SLOT(newmessage())); contextMnu.exec(QCursor::pos()); } @@ -767,7 +767,7 @@ void MessagesDialog::openAsTab() return; } - ui.tabWidget->addTab(msgWidget,QIcon(IMAGE_MAIL), msgWidget->subject(true)); + ui.tabWidget->addTab(msgWidget,FilesDefs::getIconFromQtResourcePath(IMAGE_MAIL), msgWidget->subject(true)); ui.tabWidget->setCurrentWidget(msgWidget); connect(msgWidget, SIGNAL(messageRemoved()), this, SLOT(messageRemoved())); @@ -1284,7 +1284,7 @@ void MessagesDialog::updateMessageSummaryList() QFont qf = item->font(); qf.setBold(true); item->setFont(qf); - item->setIcon(QIcon(":/images/folder-inbox-new.png")); + item->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/folder-inbox-new.png")); item->setData(Qt::ForegroundRole, mTextColorInbox); } else @@ -1294,7 +1294,7 @@ void MessagesDialog::updateMessageSummaryList() QFont qf = item->font(); qf.setBold(false); item->setFont(qf); - item->setIcon(QIcon(":/images/folder-inbox.png")); + item->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/folder-inbox.png")); item->setData(Qt::ForegroundRole, QVariant()); } @@ -1553,6 +1553,6 @@ void MessagesDialog::updateInterface() else { ui.tabWidget->setTabText(0, tr("No Box selected.")); - ui.tabWidget->setTabIcon(0, QIcon(":/icons/warning_yellow_128.png")); + ui.tabWidget->setTabIcon(0, FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); } } diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e2e933a32..3a181df2c 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include @@ -276,7 +277,7 @@ bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, con text += "" ; dialog.setText(text) ; - dialog.setWindowIcon(QIcon(":/icons/logo_128.png")); + dialog.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); dialog.setStandardButtons(QMessageBox::Yes | QMessageBox::No) ; int ret = dialog.exec(); diff --git a/retroshare-gui/src/gui/profile/ProfileManager.cpp b/retroshare-gui/src/gui/profile/ProfileManager.cpp index 0a8a80df6..7041f7201 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.cpp +++ b/retroshare-gui/src/gui/profile/ProfileManager.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -67,7 +68,7 @@ void ProfileManager::identityTreeWidgetCostumPopupMenu(QPoint) QMenu contextMnu(this); - QAction *action = contextMnu.addAction(QIcon(IMAGE_EXPORT), tr("Export Identity"), this, SLOT(exportIdentity())); + QAction *action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EXPORT), tr("Export Identity"), this, SLOT(exportIdentity())); action->setEnabled(item != NULL); contextMnu.exec(QCursor::pos()); diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 0c3c2c924..02ad43143 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -42,6 +42,7 @@ #include "gui/statusbar/SoundStatus.h" #include "gui/statusbar/ToasterDisable.h" #include "gui/statusbar/SysTrayStatus.h" +#include "gui/common/FilesDefs.h" /** Constructor */ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags) @@ -69,7 +70,7 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags) /* Populate combo boxes */ foreach (QString code, LanguageSupport::languageCodes()) { - ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code); + ui.cmboLanguage->addItem(FilesDefs::getIconFromQtResourcePath(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code); } foreach (QString style, QStyleFactory::keys()) { ui.cmboStyle->addItem(style, style.toLower()); diff --git a/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp index e6e5f67e3..fe7e36a7b 100755 --- a/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp +++ b/retroshare-gui/src/gui/settings/FileAssociationsPage.cpp @@ -19,6 +19,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include "FileAssociationsPage.h" #include "AddFileAssociationDialog.h" //#include "rshare.h" // for Rshare::dataDirectory() method @@ -60,19 +61,19 @@ FileAssociationsPage::FileAssociationsPage(QWidget * parent, Qt::WindowFlags fla QVBoxLayout* pageLay = new QVBoxLayout(this); toolBar = new QToolBar("actions", this); - newAction = new QAction(QIcon(":/icons/png/add.png"), tr("&New"), this); + newAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/add.png"), tr("&New"), this); //newAction->setShortcut(tr("Ctrl+N")); newAction->setStatusTip(tr("Add new Association")); connect(newAction, SIGNAL(triggered()), this, SLOT(addnew())); toolBar->addAction(newAction); - editAction = new QAction(QIcon(":/images/kcmsystem24.png"), + editAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/kcmsystem24.png"), tr("&Edit"), this); editAction->setStatusTip(tr("Edit this Association")); connect(editAction, SIGNAL(triggered()), this, SLOT(edit())); toolBar->addAction(editAction); - removeAction = new QAction(QIcon(":/images/edit_remove24.png"), + removeAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_remove24.png"), tr("&Remove"), this); removeAction->setStatusTip(tr("Remove this Association")); connect(removeAction, SIGNAL(triggered()), this, SLOT(remove())); diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 37291be0f..64392aa08 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -1352,7 +1352,7 @@ void ServerPage::updateInProxyIndicator() return ; //ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; - //ui.testIncomingTor_PB->setIcon(QIcon(":/loader/circleball-16.gif")) ; + //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(":/loader/circleball-16.gif")) ; QMovie *movie = new QMovie(":/images/loader/circleball-16.gif"); ui.iconlabel_service_incoming->setMovie(movie); movie->start(); @@ -1846,11 +1846,11 @@ void ServerPage::updateInProxyIndicatorResult(bool success) ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ; ui.iconlabel_service_incoming->setToolTip(tr("You are reachable through the hidden service.")) ; - //ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_OK)) ; + //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(ICON_STATUS_OK)) ; } else { std::cerr <<"Failed!" << std::endl; - //ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_UNKNOWN)) ; + //ui.testIncomingTor_PB->setIcon(FilesDefs::getIconFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ; ui.iconlabel_service_incoming->setToolTip(tr("The proxy is not enabled or broken.\nAre all services up and running fine??\nAlso check your ports!")) ; } diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 7a9864fff..9b584162e 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -21,6 +21,7 @@ #ifndef RSETTINGSWIN_HPP_ #define RSETTINGSWIN_HPP_ +#include "gui/common/FilesDefs.h" #include #include #include "ui_settingsw.h" @@ -44,7 +45,7 @@ public: void postModDirectories(bool update_local); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_PREFERENCES) ; } //MainPage + virtual QIcon iconPixmap() const { return FilesDefs::getIconFromQtResourcePath(IMAGE_PREFERENCES) ; } //MainPage virtual QString pageName() const { return tr("Preferences") ; } //MainPage protected: diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index 0a992353b..1fc583b18 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -126,7 +126,7 @@ void GlobalRouterStatistics::CustomPopupMenu( QPoint ) QTreeWidgetItem *item = treeWidget->currentItem(); if (item) { - contextMnu.addAction(QIcon(":/images/info16.png"), tr("Details"), this, SLOT(personDetails())); + contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/info16.png"), tr("Details"), this, SLOT(personDetails())); } diff --git a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp index 50c947822..3d3868135 100644 --- a/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp +++ b/retroshare-gui/src/gui/statistics/StatisticsWindow.cpp @@ -34,6 +34,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include #include @@ -140,22 +141,22 @@ void StatisticsWindow::initStackedPage() QAction *action; ui->stackPages->add(bwdlg = new BwCtrlWindow(ui->stackPages), - action = createPageAction(QIcon(IMAGE_BWGRAPH), tr("Bandwidth"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_BWGRAPH), tr("Bandwidth"), grp)); ui->stackPages->add(trsdlg = new TurtleRouterStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle Router"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_TURTLE), tr("Turtle Router"), grp)); ui->stackPages->add(gxsiddlg = new GxsIdStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_IDENTITIES), tr("Identities"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_IDENTITIES), tr("Identities"), grp)); ui->stackPages->add(grsdlg = new GlobalRouterStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_GLOBALROUTER), tr("Global Router"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GLOBALROUTER), tr("Global Router"), grp)); ui->stackPages->add(gxsdlg = new GxsTransportStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_GXSTRANSPORT), tr("Gxs Transport"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GXSTRANSPORT), tr("Gxs Transport"), grp)); ui->stackPages->add(rttdlg = new RttStatistics(ui->stackPages), - action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_RTT), tr("RTT Statistics"), grp)); bool showdht = true; RsPeerDetails detail; @@ -167,7 +168,7 @@ void StatisticsWindow::initStackedPage() if(showdht) { ui->stackPages->add(dhtw = new DhtWindow(ui->stackPages), - action = createPageAction(QIcon(IMAGE_DHT), tr("DHT"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DHT), tr("DHT"), grp)); } /*std::cerr << "Looking for interfaces in existing plugins:" << std::endl; @@ -180,7 +181,7 @@ void StatisticsWindow::initStackedPage() if(rsPlugins->plugin(i)->qt_icon() != NULL) icon = *rsPlugins->plugin(i)->qt_icon() ; else - icon = QIcon(":images/extension_48.png") ; + icon = FilesDefs::getIconFromQtResourcePath(":images/extension_48.png") ; std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl; MainPage *pluginPage = rsPlugins->plugin(i)->qt_page(); diff --git a/retroshare-gui/src/gui/statusbar/SoundStatus.cpp b/retroshare-gui/src/gui/statusbar/SoundStatus.cpp index 531133008..374a61b12 100644 --- a/retroshare-gui/src/gui/statusbar/SoundStatus.cpp +++ b/retroshare-gui/src/gui/statusbar/SoundStatus.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include @@ -54,6 +55,6 @@ SoundStatus::SoundStatus(QWidget *parent) void SoundStatus::mute(bool isMute) { - imageButton->setIcon(QIcon(isMute ? IMAGE_MUTE_ON : IMAGE_MUTE_OFF)); + imageButton->setIcon(FilesDefs::getIconFromQtResourcePath(isMute ? IMAGE_MUTE_ON : IMAGE_MUTE_OFF)); imageButton->setToolTip(isMute ? tr("Sound is off, click to turn it on") : tr("Sound is on, click to turn it off")); } diff --git a/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp b/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp index b465e83e3..1f52163ec 100644 --- a/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp +++ b/retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp @@ -18,6 +18,7 @@ * * *******************************************************************************/ +#include "gui/common/FilesDefs.h" #include #include #include @@ -36,7 +37,7 @@ SysTrayStatus::SysTrayStatus(QWidget *parent) : hbox->setSpacing(0); imageButton = new QPushButton(this); - imageButton->setIcon(QIcon(IMAGE_NOONLINE)); + imageButton->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_NOONLINE)); imageButton->setFlat(true); imageButton->setCheckable(false); imageButton->setFocusPolicy(Qt::ClickFocus); diff --git a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp index 9db4326a4..923d1ba88 100644 --- a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp +++ b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp @@ -74,7 +74,7 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WindowFlags flags) //StatisticDialog *statisticDialog = NULL; //ui.stackPages->add(statisticDialog = new StatisticDialog(ui.stackPages), - // createPageAction(QIcon(IMAGE_STATISTIC), tr("Statistics"), grp)); + // createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_STATISTIC), tr("Statistics"), grp)); //GamesDialog *gamesDialog = NULL; //ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages), @@ -91,7 +91,7 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WindowFlags flags) #ifdef RS_USE_CIRCLES CirclesDialog *circlesDialog = NULL; ui.stackPages->add(circlesDialog = new CirclesDialog(ui.stackPages), - action = createPageAction(QIcon(IMAGE_CIRCLES ), tr("Circles"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_CIRCLES ), tr("Circles"), grp)); mNotify.push_back(QPair(circlesDialog, action)); #endif #endif @@ -105,13 +105,13 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WindowFlags flags) /*PostedDialog *postedDialog = NULL; ui.stackPages->add(postedDialog = new PostedDialog(ui.stackPages), - action = createPageAction(QIcon(IMAGE_POSTED), tr("Posted Links"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_POSTED), tr("Posted Links"), grp)); postedDialog->setup(); mNotify.push_back(QPair(postedDialog, action)); WikiDialog *wikiDialog = NULL; ui.stackPages->add(wikiDialog = new WikiDialog(ui.stackPages), - action = createPageAction(QIcon(IMAGE_WIKI), tr("Wiki Pages"), grp)); + action = createPageAction(FilesDefs::getIconFromQtResourcePath(IMAGE_WIKI), tr("Wiki Pages"), grp)); mNotify.push_back(QPair(wikiDialog, action));*/ // THESE HAVE TO BE CONVERTED TO VEG FORMAT diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 490878e57..4c427d289 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -30,6 +30,7 @@ CrashStackTrace gCrashStackTrace; #include #include +#include "gui/common/FilesDefs.h" #include "gui/FriendsDialog.h" #include "gui/GenCertDialog.h" #include "gui/MainWindow.h" @@ -136,7 +137,7 @@ static void displayWarningAboutDSAKeys() msgBox.setInformativeText(QObject::tr("DSA keys are not yet supported by this version of RetroShare. All these nodes will be unusable. We're very sorry for that.")); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setWindowIcon(QIcon(":/icons/logo_128.png")); + msgBox.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); msgBox.exec(); } @@ -270,7 +271,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); msgBox.setInformativeText(QObject::tr("Choose between:
  • Ok to copy the existing keyring from gnupg (safest bet), or
  • Close without saving to start fresh with an empty keyring (you will be asked to create a new PGP key to work with RetroShare, or import a previously saved pgp keypair).
  • Cancel to quit and forge a keyring by yourself (needs some PGP skills)
")); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setWindowIcon(QIcon(":/icons/logo_128.png")); + msgBox.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); int ret = msgBox.exec(); @@ -299,7 +300,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); displayWarningAboutDSAKeys(); QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok); - mb.setWindowIcon(QIcon(":/icons/logo_128.png")); + mb.setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); switch (initResult) { diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index 3898a899a..cbed6698a 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -42,6 +42,7 @@ #include #include +#include "gui/common/FilesDefs.h" #include #include #include @@ -258,7 +259,7 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir) #ifndef __APPLE__ /* set default window icon */ - setWindowIcon(QIcon(":/icons/logo_128.png")); + setWindowIcon(FilesDefs::getIconFromQtResourcePath(":/icons/logo_128.png")); #endif From 3b7734c934d8f183100585c71ed7e1eb6e9bab35 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 16 Aug 2020 22:17:54 +0200 Subject: [PATCH 08/21] uniformise calls to [begin/end]ResetModel() and removed calls to layoutAboutToBeChanged() as it may cause some SIGSEGV --- retroshare-gui/src/gui/RemoteDirModel.cpp | 18 +++--------------- .../src/gui/common/FriendListModel.cpp | 6 ++---- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index b69929778..7ea0e9fa8 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -1103,15 +1103,9 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const /* Callback from Core*/ void RetroshareDirModel::preMods() { - emit layoutAboutToBeChanged(); mUpdating = true ; -#if QT_VERSION < 0x050000 - reset(); -#else - beginResetModel(); - endResetModel(); -#endif + beginResetModel(); #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::preMods()" << std::endl; #endif @@ -1120,20 +1114,14 @@ void RetroshareDirModel::preMods() /* Callback from Core*/ void RetroshareDirModel::postMods() { -// emit layoutAboutToBeChanged(); mUpdating = false ; -#if QT_VERSION >= 0x040600 - beginResetModel(); -#endif - #ifdef RDM_DEBUG std::cerr << "RetroshareDirModel::postMods()" << std::endl; #endif -#if QT_VERSION >= 0x040600 endResetModel(); -#endif - emit layoutChanged(); + + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,COLUMN_COUNT-1,(void*)NULL)); } void FlatStyle_RDM::postMods() diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 74d5d8746..408527b3e 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -152,15 +152,13 @@ void RsFriendListModel::setDisplayGroups(bool b) } void RsFriendListModel::preMods() { - emit layoutAboutToBeChanged(); - beginResetModel(); } void RsFriendListModel::postMods() { endResetModel(); - emit layoutChanged(); - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); + + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); } int RsFriendListModel::rowCount(const QModelIndex& parent) const From 8c845d7419cf7736d29474681c695fb1cfe66a95 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 17 Aug 2020 21:47:27 +0200 Subject: [PATCH 09/21] fixed marking all msgs as read/unread in channels --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 25 +++++++++++++------ .../gui/gxschannels/GxsChannelPostsModel.h | 4 ++- .../GxsChannelPostsWidgetWithModel.cpp | 14 +++++------ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 47f46bfe9..58715e48d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -171,7 +171,7 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings, uint32_t& cou if(strings.empty()) { mFilteredPosts.clear(); - for(int i=0;i= mColumns) + if(row < 0 || column < 0 || column >= (int)mColumns) return QModelIndex(); quintptr ref = getChildRef(parent.internalId(),column + row*mColumns); @@ -684,7 +684,19 @@ void RsGxsChannelPostsModel::createPostsArray(std::vector& pos } } -void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status,bool with_children) +void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) +{ + // No need to call preMods()/postMods() here because we're not changing the model + // All operations below are done async + + RsThread::async([this, read_status]() + { + for(uint32_t i=0;imarkRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status); + }); +} + +void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_status) { if(!i.isValid()) return ; @@ -697,10 +709,7 @@ void RsGxsChannelPostsModel::setMsgReadStatus(const QModelIndex& i,bool read_sta if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFilteredPosts.size()) return ; -#warning TODO -// bool has_unread_below, has_read_below; -// recursSetMsgReadStatus(entry,read_status,with_children) ; -// recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below); + rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[mFilteredPosts[entry]].mMeta.mGroupId,mPosts[mFilteredPosts[entry]].mMeta.mMsgId),read_status); } QModelIndex RsGxsChannelPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) const diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index 6ceedddfb..47e0caee5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -127,7 +127,9 @@ public: void setTextColorMissing (QColor color) { mTextColorMissing = color;} #endif - void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children); + void setMsgReadStatus(const QModelIndex &i, bool read_status); + void setAllMsgReadStatus(bool read_status); + void setFilter(const QStringList &strings, uint32_t &count) ; #ifdef TODO diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index d07f4ad74..093c5b12c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -1148,6 +1148,7 @@ public: uint32_t mLastToken; }; +#ifdef TO_REMOVE static void setAllMessagesReadCallback(FeedItem *feedItem, void *data) { GxsChannelPostItem *channelPostItem = dynamic_cast(feedItem); @@ -1164,16 +1165,15 @@ static void setAllMessagesReadCallback(FeedItem *feedItem, void *data) RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId()); rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead); } +#endif -void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t &token) +void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t& /*token*/) { - if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { - return; - } + if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) + return; - GxsChannelPostsReadData data(read); - //ui->feedWidget->withAll(setAllMessagesReadCallback, &data); + QModelIndex src_index; - token = data.mLastToken; + mChannelPostsModel->setAllMsgReadStatus(read); } From f8989ce9446bdf1e09cf37ad1ef12c1dda6e95fc Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 17 Aug 2020 21:56:53 +0200 Subject: [PATCH 10/21] added test bit about mouse wheel + control in channels --- retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index a70fdf395..09dec15c7 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -108,6 +108,7 @@ QString GxsChannelDialog::getHelpString() const

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)); return hlp_str ; From 09c7fdee4b9e26cf1fcfd9ee49ebebe09ed4b057 Mon Sep 17 00:00:00 2001 From: drbob Date: Tue, 18 Aug 2020 22:43:45 +1000 Subject: [PATCH 11/21] Add proper header path for 'retroshare-gui/' headers This is simplifies the include directories needed for plugins. --- retroshare-gui/src/gui/ChatLobbyWidget.h | 3 ++- retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h | 2 +- retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h | 3 ++- retroshare-gui/src/gui/FileTransfer/SearchDialog.h | 2 +- retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h | 2 +- retroshare-gui/src/gui/FileTransfer/TransfersDialog.h | 2 +- retroshare-gui/src/gui/GetStartedDialog.h | 4 ++-- retroshare-gui/src/gui/NetworkDialog.h | 4 +++- retroshare-gui/src/gui/NetworkView.h | 2 +- retroshare-gui/src/gui/NewsFeed.h | 2 +- retroshare-gui/src/gui/PluginsPage.h | 2 +- retroshare-gui/src/gui/RemoteDirModel.cpp | 3 ++- retroshare-gui/src/gui/RsAutoUpdatePage.cpp | 3 ++- retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp | 3 ++- retroshare-gui/src/gui/common/NewFriendList.h | 3 ++- retroshare-gui/src/gui/connect/ConfCertDialog.cpp | 3 ++- retroshare-gui/src/gui/connect/PGPKeyDialog.cpp | 3 ++- retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h | 3 ++- retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h | 2 +- retroshare-gui/src/gui/msgs/MessagesDialog.h | 3 ++- retroshare-gui/src/gui/notifyqt.cpp | 2 +- retroshare-gui/src/gui/settings/rsettingswin.h | 3 ++- retroshare-gui/src/gui/statistics/BwCtrlWindow.h | 2 +- retroshare-gui/src/gui/statistics/DhtWindow.h | 3 ++- retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h | 3 ++- retroshare-gui/src/gui/statistics/GxsIdStatistics.h | 3 ++- retroshare-gui/src/gui/statistics/GxsTransportStatistics.h | 3 ++- retroshare-gui/src/gui/statistics/RttStatistics.h | 3 ++- retroshare-gui/src/gui/statistics/TurtleRouterDialog.h | 4 +++- retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h | 4 +++- retroshare-gui/src/retroshare-gui.pro | 4 ++-- 31 files changed, 55 insertions(+), 33 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index 415c28bc2..a9bb01895 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -19,9 +19,10 @@ *******************************************************************************/ #pragma once +#include + #include "ui_ChatLobbyWidget.h" -#include "RsAutoUpdatePage.h" #include "chat/ChatLobbyUserNotify.h" #include "gui/gxs/GxsIdChooser.h" diff --git a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h index 28b8e8df1..a65dac238 100644 --- a/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.h @@ -20,7 +20,7 @@ #pragma once -#include "RsAutoUpdatePage.h" +#include #include "ui_BannedFilesDialog.h" class BannedFilesDialog: public QDialog diff --git a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h index a82f08dbc..fdf45f2ff 100644 --- a/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h +++ b/retroshare-gui/src/gui/FileTransfer/FileTransferInfoWidget.h @@ -24,7 +24,8 @@ #include #include #include -#include "RsAutoUpdatePage.h" + +#include #include struct FileChunksInfo ; diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index c911b8084..f14bfb642 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -23,7 +23,7 @@ #include #include "ui_SearchDialog.h" -#include "mainpage.h" +#include class AdvancedSearchDialog; class RSTreeWidgetItemCompareRole; diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h index 5206e1d06..86164a7f3 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.h @@ -23,7 +23,7 @@ #include "ui_SharedFilesDialog.h" -#include "RsAutoUpdatePage.h" +#include #include "gui/RetroShareLink.h" #include "util/RsProtectedTimer.h" diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h index 9c03e830c..e11f6c232 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h @@ -25,7 +25,7 @@ #include #include -#include "RsAutoUpdatePage.h" +#include #include "ui_TransfersDialog.h" diff --git a/retroshare-gui/src/gui/GetStartedDialog.h b/retroshare-gui/src/gui/GetStartedDialog.h index 8705d0290..6d943958a 100644 --- a/retroshare-gui/src/gui/GetStartedDialog.h +++ b/retroshare-gui/src/gui/GetStartedDialog.h @@ -21,9 +21,9 @@ #ifndef _GETTING_STARTED_DIALOG_H #define _GETTING_STARTED_DIALOG_H -//#include +#include + #include "ui_GetStartedDialog.h" -#include "mainpage.h" #include diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 8391ad476..9561c1db3 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -21,8 +21,10 @@ #ifndef _CONNECTIONSDIALOG_H #define _CONNECTIONSDIALOG_H +#include + #include "ui_NetworkDialog.h" -#include "RsAutoUpdatePage.h" + #include "gui/NetworkDialog/pgpid_item_model.h" #include "gui/NetworkDialog/pgpid_item_proxy.h" diff --git a/retroshare-gui/src/gui/NetworkView.h b/retroshare-gui/src/gui/NetworkView.h index 274ca020b..f6fcfe0b1 100644 --- a/retroshare-gui/src/gui/NetworkView.h +++ b/retroshare-gui/src/gui/NetworkView.h @@ -25,7 +25,7 @@ #include -#include "RsAutoUpdatePage.h" +#include #include "ui_NetworkView.h" diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 713bcf96c..869d654fd 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -21,7 +21,7 @@ #ifndef _NEWS_FEED_DIALOG_H #define _NEWS_FEED_DIALOG_H -#include "mainpage.h" +#include #include "gui/feeds/FeedHolder.h" #include "util/TokenQueue.h" diff --git a/retroshare-gui/src/gui/PluginsPage.h b/retroshare-gui/src/gui/PluginsPage.h index 4832a1ac6..36d4f9c8a 100644 --- a/retroshare-gui/src/gui/PluginsPage.h +++ b/retroshare-gui/src/gui/PluginsPage.h @@ -21,7 +21,7 @@ #ifndef _PLUGINS_PAGE_H_ #define _PLUGINS_PAGE_H_ -#include "mainpage.h" +#include #include #include diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index b69929778..f10f0d55e 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -20,7 +20,8 @@ #include "RemoteDirModel.h" -#include "RsAutoUpdatePage.h" +#include + #include "gui/common/FilesDefs.h" #include "gui/common/GroupDefs.h" #include "gui/common/RsCollection.h" diff --git a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp index 03d231cf0..4c18d294b 100644 --- a/retroshare-gui/src/gui/RsAutoUpdatePage.cpp +++ b/retroshare-gui/src/gui/RsAutoUpdatePage.cpp @@ -19,7 +19,8 @@ *******************************************************************************/ #include -#include "RsAutoUpdatePage.h" + +#include bool RsAutoUpdatePage::_locked = false ; diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index b93c2d438..840a03d47 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -30,7 +30,8 @@ #include #include -#include "RsAutoUpdatePage.h" +#include + #include "PopupDistantChatDialog.h" #define IMAGE_RED_LED ":/icons/bullet_red_128.png" diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 2a1955ced..4bdeddd4b 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -25,8 +25,9 @@ #include #include +#include + #include "FriendListModel.h" -#include "RsAutoUpdatePage.h" #include "retroshare/rsstatus.h" namespace Ui { diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index fc56ebef5..92ab22142 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -32,6 +32,8 @@ #include #include +#include + #include "gui/help/browser/helpbrowser.h" #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" @@ -39,7 +41,6 @@ #include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/MainWindow.h" -#include "mainpage.h" #include "util/DateTime.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index d27e779fd..cd9199c31 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -32,6 +32,8 @@ #include #include +#include + #include "gui/help/browser/helpbrowser.h" #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" @@ -39,7 +41,6 @@ #include "gui/notifyqt.h" #include "gui/common/AvatarDefs.h" #include "gui/MainWindow.h" -#include "mainpage.h" #include "util/DateTime.h" #include "util/misc.h" diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index 006f593a4..eaf1d0d34 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -21,8 +21,9 @@ #ifndef _GXSGROUPFRAMEDIALOG_H #define _GXSGROUPFRAMEDIALOG_H +#include + #include "gui/gxs/RsGxsUpdateBroadcastPage.h" -#include "RsAutoUpdatePage.h" #include "gui/RetroShareLink.h" #include "gui/settings/rsharesettings.h" #include "util/RsUserdata.h" diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h index 2e13e0910..2a983bf8d 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h @@ -20,7 +20,7 @@ #pragma once -#include "mainpage.h" +#include #include // This class implement a basic RS functionality which is that widgets displaying info diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index abc80349d..bf0148cf5 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -23,7 +23,8 @@ #include -#include "mainpage.h" +#include + #include "ui_MessagesDialog.h" #define IMAGE_MESSAGES ":/icons/png/message.png" diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index e2e933a32..b85a946e1 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -32,7 +32,7 @@ #include #include -#include "RsAutoUpdatePage.h" +#include #include "MainWindow.h" #include "toaster/OnlineToaster.h" diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 7a9864fff..2807d6443 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -23,8 +23,9 @@ #include #include +#include + #include "ui_settingsw.h" -#include "mainpage.h" class FloatingHelpBrowser; diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.h b/retroshare-gui/src/gui/statistics/BwCtrlWindow.h index d47867d4f..4126eb6bc 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.h +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.h @@ -24,7 +24,7 @@ #include -#include "RsAutoUpdatePage.h" +#include #include "gui/common/RSGraphWidget.h" #include "ui_BwCtrlWindow.h" diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.h b/retroshare-gui/src/gui/statistics/DhtWindow.h index 8199b5a1d..795a80a36 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.h +++ b/retroshare-gui/src/gui/statistics/DhtWindow.h @@ -21,7 +21,8 @@ #ifndef RSDHT_WINDOW_H #define RSDHT_WINDOW_H -#include "RsAutoUpdatePage.h" +#include + #include "ui_DhtWindow.h" class DhtWindow : public RsAutoUpdatePage/*, public Ui::DhtWindow*/ { diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h index c8d132740..c8e49fb4a 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.h @@ -24,7 +24,8 @@ #include #include -#include "RsAutoUpdatePage.h" +#include + #include "ui_GlobalRouterStatistics.h" class GlobalRouterStatisticsWidget ; diff --git a/retroshare-gui/src/gui/statistics/GxsIdStatistics.h b/retroshare-gui/src/gui/statistics/GxsIdStatistics.h index 9d101aa88..fc0ab93fd 100644 --- a/retroshare-gui/src/gui/statistics/GxsIdStatistics.h +++ b/retroshare-gui/src/gui/statistics/GxsIdStatistics.h @@ -24,7 +24,8 @@ #include #include -#include "RsAutoUpdatePage.h" +#include + #include "Histogram.h" #include "ui_GxsIdStatistics.h" diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h index d23fdaa0f..0b9970c1c 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.h @@ -27,7 +27,8 @@ #include #include -#include "RsAutoUpdatePage.h" +#include + #include "ui_GxsTransportStatistics.h" #include "gui/gxs/RsGxsUpdateBroadcastPage.h" #include "util/rstime.h" diff --git a/retroshare-gui/src/gui/statistics/RttStatistics.h b/retroshare-gui/src/gui/statistics/RttStatistics.h index 2cefe3bb7..32c8b4f1b 100644 --- a/retroshare-gui/src/gui/statistics/RttStatistics.h +++ b/retroshare-gui/src/gui/statistics/RttStatistics.h @@ -22,8 +22,9 @@ #include #include +#include + #include "ui_RttStatistics.h" -#include "RsAutoUpdatePage.h" #include class RttStatisticsWidget ; diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h index 4fc00b004..94e1ce269 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.h @@ -22,9 +22,11 @@ #include #include + +#include + #include "ui_TurtleRouterDialog.h" #include "ui_TurtleRouterStatistics.h" -#include "RsAutoUpdatePage.h" class TurtleRouterDialog: public RsAutoUpdatePage, public Ui::TurtleRouterDialogForm diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h index f7613de94..7cba37c18 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h +++ b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.h @@ -23,8 +23,10 @@ #include #include #include + +#include + #include "ui_TurtleRouterStatistics.h" -#include "RsAutoUpdatePage.h" class TurtleRouterStatisticsWidget ; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index fdbc83083..fbb600013 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -25,8 +25,8 @@ CONFIG += console TARGET = retroshare DEFINES += TARGET=\\\"$${TARGET}\\\" -DEPENDPATH *= $${PWD} $${RS_INCLUDE_DIR} retroshare-gui -INCLUDEPATH *= $${PWD} retroshare-gui +DEPENDPATH *= $${PWD} $${RS_INCLUDE_DIR} +INCLUDEPATH *= $${PWD} !include("../../libretroshare/src/use_libretroshare.pri"):error("Including") From 7c5bf2293192f4d29997190b3af6bde72cce083c Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 20 Aug 2020 18:34:10 +0200 Subject: [PATCH 12/21] improved safety of underlying data update for FriendListModel --- .../src/gui/common/FriendListModel.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 408527b3e..abd1c7450 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -1058,14 +1058,16 @@ void RsFriendListModel::updateInternalData() preMods(); beginRemoveRows(QModelIndex(),0,mTopLevel.size()-1); - endRemoveRows(); mGroups.clear(); mProfiles.clear(); mLocations.clear(); - mTopLevel.clear(); + endRemoveRows(); + + auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows(). + // create a map of profiles and groups std::map pgp_indices; @@ -1153,7 +1155,6 @@ void RsFriendListModel::updateInternalData() RsDbg() << "Creating top level list" << std::endl; #endif - mTopLevel.clear(); std::set already_in_a_group; if(mDisplayGroups) // in this case, we list all groups at the top level followed by the profiles without parent group @@ -1168,7 +1169,7 @@ void RsFriendListModel::updateInternalData() e.type = ENTRY_TYPE_GROUP; e.group_index = i; - mTopLevel.push_back(e); + TL.push_back(e); for(uint32_t j=0;j Date: Fri, 21 Aug 2020 18:42:12 +0200 Subject: [PATCH 13/21] hack to fix crashes in network list --- retroshare-gui/src/gui/common/NewFriendList.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 9d9908642..95e0c844c 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -1094,9 +1094,15 @@ void NewFriendList::checkInternalData(bool force) saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); + // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are + // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this soves them for good. + + mProxyModel->setSourceModel(nullptr); + mModel->checkInternalData(force); - restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); + mProxyModel->setSourceModel(mModel); + restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); } void NewFriendList::exportFriendlistClicked() From cffd0a71af67c2ddc50ebfadc24186a600c169e1 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 21 Aug 2020 22:41:34 +0200 Subject: [PATCH 14/21] removed hardcoded stylesheets from the frames --- retroshare-gui/src/gui/TheWire/PulseReply.ui | 5 +---- retroshare-gui/src/gui/TheWire/PulseTopLevel.ui | 5 +---- retroshare-gui/src/gui/TheWire/PulseViewGroup.ui | 5 +---- retroshare-gui/src/gui/qss/stylesheet/Standard.qss | 6 ++++++ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/PulseReply.ui b/retroshare-gui/src/gui/TheWire/PulseReply.ui index 582ceb269..9925d19bd 100644 --- a/retroshare-gui/src/gui/TheWire/PulseReply.ui +++ b/retroshare-gui/src/gui/TheWire/PulseReply.ui @@ -40,10 +40,7 @@ - QFrame#frame{border: 2px solid #CCCCCC; -background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #EEEEEE, stop: 1 #CCCCCC); -border-radius: 10px} + QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui b/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui index 77d32218a..f3365825a 100644 --- a/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui +++ b/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui @@ -40,10 +40,7 @@ - QFrame#frame{border: 2px solid #CCCCCC; -background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #EEEEEE, stop: 1 #CCCCCC); -border-radius: 10px} + QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui b/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui index 7f808dd44..c2f209a19 100644 --- a/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui +++ b/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui @@ -40,10 +40,7 @@ - QFrame#frame{border: 2px solid #CCCCCC; -background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #EEEEEE, stop: 1 #CCCCCC); -border-radius: 10px} + QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index eb12e6551..7ab47c667 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -928,3 +928,9 @@ MessagesDialog QWidget#messageTreeWidget::item:hover { GxsForumThreadWidget QWidget#threadTreeWidget::item { padding: 2px; } + +PulseTopLevel QFrame#frame, PulseViewGroup QFrame#frame, PulseReply QFrame#frame { + border: 2px solid #7ecbfb; + border-radius: 6px; + background: white; +} From da21a40eda55da2fbeab4b4bf161cc6bb2c90b52 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 22 Aug 2020 19:14:46 +0200 Subject: [PATCH 15/21] keep expand state when showing/hiding IPs and last connection state --- .../src/gui/common/NewFriendList.cpp | 19 +++++++++++++------ retroshare-gui/src/gui/common/NewFriendList.h | 4 +++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 95e0c844c..a388c9dea 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -453,6 +453,7 @@ void NewFriendList::processSettings(bool load) if (load) // load settings { + std::cerr <<"Re-loading settings..." << std::endl; // states setShowUnconnected(!Settings->value("hideUnconnected", !mProxyModel->showOfflineNodes()).toBool()); setShowState(Settings->value("showState", mModel->getDisplayStatusString()).toBool()); @@ -1087,24 +1088,29 @@ void NewFriendList::removeGroup() checkInternalData(true); } -void NewFriendList::checkInternalData(bool force) +void NewFriendList::applyWhileKeepingTree(std::function predicate) { std::set expanded_indexes; - std::set selected_indexes; + std::set selected_indexes; - saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); + saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this soves them for good. mProxyModel->setSourceModel(nullptr); - mModel->checkInternalData(force); + predicate(); mProxyModel->setSourceModel(mModel); restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); } +void NewFriendList::checkInternalData(bool force) +{ + applyWhileKeepingTree([force,this]() { mModel->checkInternalData(force) ; }); +} + void NewFriendList::exportFriendlistClicked() { QString fileName; @@ -1490,6 +1496,7 @@ bool NewFriendList::isColumnVisible(int col) const } void NewFriendList::setColumnVisible(int col,bool visible) { + std::cerr << "Setting column " << col << " to be visible: " << visible << std::endl; ui->peerTreeWidget->setColumnHidden(col, !visible); } void NewFriendList::toggleColumnVisible() @@ -1507,12 +1514,12 @@ void NewFriendList::toggleColumnVisible() void NewFriendList::setShowState(bool show) { - mModel->setDisplayStatusString(show); + applyWhileKeepingTree([show,this]() { mModel->setDisplayStatusString(show) ; }); } void NewFriendList::setShowGroups(bool show) { - mModel->setDisplayGroups(show); + applyWhileKeepingTree([show,this]() { mModel->setDisplayGroups(show) ; }); } /** diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 2a1955ced..cf026b81b 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -102,7 +102,9 @@ private: RsFriendListModel *mModel; QAction *mActionSortByState; - void expandGroup(const RsNodeGroupId& gid); + void applyWhileKeepingTree(std::function predicate); + + void expandGroup(const RsNodeGroupId& gid); void recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set& exp, const std::set &sel); void recursSaveExpandedItems(const QModelIndex& index,const QString& parent_path,std::set& exp, std::set& sel); void saveExpandedPathsAndSelection(std::set& expanded_indexes, std::set& selected_indexes); From 44444207f79e1f98142ea85e3e7655f5755b2202 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 22 Aug 2020 20:23:42 +0200 Subject: [PATCH 16/21] save/restore hidden columns when switching which column is visible in FriendList --- retroshare-gui/src/gui/common/FriendListModel.cpp | 8 ++++---- retroshare-gui/src/gui/common/NewFriendList.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index abd1c7450..39d4bbded 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -158,7 +158,7 @@ void RsFriendListModel::postMods() { endResetModel(); - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,columnCount()-1,(void*)NULL)); } int RsFriendListModel::rowCount(const QModelIndex& parent) const @@ -1236,7 +1236,7 @@ void RsFriendListModel::collapseItem(const QModelIndex& index) mExpandedProfiles.erase(s); // apparently we cannot be subtle here. - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,columnCount()-1,(void*)NULL)); } void RsFriendListModel::expandItem(const QModelIndex& index) @@ -1258,10 +1258,10 @@ void RsFriendListModel::expandItem(const QModelIndex& index) if(hp) s += hp->profile_info.gpg_id.toStdString(); if(!s.empty()) - mExpandedProfiles.insert(s); + mExpandedProfiles.insert(s); // apparently we cannot be subtle here. - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,columnCount()-1,(void*)NULL)); } bool RsFriendListModel::isProfileExpanded(const EntryIndex& e) const diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index a388c9dea..501be9a3c 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -1096,7 +1096,13 @@ void NewFriendList::applyWhileKeepingTree(std::function predicate) saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are - // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this soves them for good. + // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this solves them for good. + + // save hidden columns + std::list hidden_columns; + for(int i=0;ipeerTreeWidget->isColumnHidden(i)) + hidden_columns.push_back(i); mProxyModel->setSourceModel(nullptr); @@ -1104,6 +1110,10 @@ void NewFriendList::applyWhileKeepingTree(std::function predicate) mProxyModel->setSourceModel(mModel); restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); + + // restore hidden columns + for(auto c: hidden_columns) + ui->peerTreeWidget->setColumnHidden(c,true); } void NewFriendList::checkInternalData(bool force) From daf92ce62cf480b96a16f3dcea6b66423bf411ee Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 22 Aug 2020 20:46:39 +0200 Subject: [PATCH 17/21] save both column width and column visibility in friend list --- .../src/gui/common/NewFriendList.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 501be9a3c..5df637116 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -1097,12 +1097,18 @@ void NewFriendList::applyWhileKeepingTree(std::function predicate) // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this solves them for good. + // As a side effect we need to save/restore hidden columns because setSourceModel() resets this setting. + + // save hidden columns and sizes + std::vector col_visible(RsFriendListModel::COLUMN_THREAD_NB_COLUMNS); + std::vector col_sizes(RsFriendListModel::COLUMN_THREAD_NB_COLUMNS); - // save hidden columns - std::list hidden_columns; for(int i=0;ipeerTreeWidget->isColumnHidden(i)) - hidden_columns.push_back(i); + { + col_visible[i] = !ui->peerTreeWidget->isColumnHidden(i); + col_sizes[i] = ui->peerTreeWidget->columnWidth(i); + } + mProxyModel->setSourceModel(nullptr); @@ -1112,8 +1118,11 @@ void NewFriendList::applyWhileKeepingTree(std::function predicate) restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); // restore hidden columns - for(auto c: hidden_columns) - ui->peerTreeWidget->setColumnHidden(c,true); + for(uint32_t i=0;ipeerTreeWidget->setColumnHidden(i,!col_visible[i]); + ui->peerTreeWidget->setColumnWidth(i,col_sizes[i]); + } } void NewFriendList::checkInternalData(bool force) From 047f51c824167caff90b0c4e0c75e0b691ee4596 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 23 Aug 2020 17:20:52 +0200 Subject: [PATCH 18/21] update dark stylesheets --- retroshare-gui/src/qss/qdarkstyle-v2.qss | 9 +++++++-- retroshare-gui/src/qss/qdarkstyle.qss | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/qss/qdarkstyle-v2.qss b/retroshare-gui/src/qss/qdarkstyle-v2.qss index cb573d765..4f6ee1cae 100644 --- a/retroshare-gui/src/qss/qdarkstyle-v2.qss +++ b/retroshare-gui/src/qss/qdarkstyle-v2.qss @@ -2143,8 +2143,8 @@ PostedCardView > QFrame#mainFrame[new=true] { background-color: #005000; } -WireGroupItem QFrame#frame{ - background: transparent; +WireGroupItem QFrame#wire_frame{ + background: transparent; } GxsChannelDialog GroupTreeWidget QTreeWidget#treeWidget::item{ @@ -2157,3 +2157,8 @@ RSTextBrowser, MimeTextEdit /*qproperty-textColorQuote: rgb(125, 125, 255);*/ qproperty-textColorQuotes: ColorList(#789922 #039bd5 #800000 #800080 #008080 #b10dc9 #85144b #3d9970); } + +PulseTopLevel QFrame#frame, PulseViewGroup QFrame#frame, PulseReply QFrame#frame { + border: 2px solid #38444d; + border-radius: 6px; +} diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index b50eb9aa1..64404cc45 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -1295,7 +1295,9 @@ PostedCardView > QFrame#mainFrame[new=true] { background-color: #005000; } -WireGroupItem QFrame#frame{ +WireGroupItem QFrame#wire_frame +{ + border: 1px solid #38444d; background: transparent; } @@ -1307,5 +1309,10 @@ RSTextBrowser, MimeTextEdit ChatWidget QFrame#pluginTitleFrame { - background: transparent; + background: transparent; +} + +PulseTopLevel QFrame#frame, PulseViewGroup QFrame#frame, PulseReply QFrame#frame { + border: 2px solid #38444d; + border-radius: 6px; } From 162028abd0dcb84bc774f67694f35b2e1e1ec2fb Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 1 Sep 2020 12:01:38 +0200 Subject: [PATCH 19/21] Remove a bunch of deadcode --- libretroshare/src/gxs/rsgxsdata.cc | 1 - libretroshare/src/gxs/rsgxsdata.h | 2 -- libretroshare/src/gxs/rsgxsutil.h | 28 +------------------ .../libretroshare/gxs/common/data_support.cc | 1 - 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsdata.cc b/libretroshare/src/gxs/rsgxsdata.cc index c3c9b9f08..b83096575 100644 --- a/libretroshare/src/gxs/rsgxsdata.cc +++ b/libretroshare/src/gxs/rsgxsdata.cc @@ -196,7 +196,6 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize) return ok; } -int RsGxsMsgMetaData::refcount = 0; RsGxsMsgMetaData::RsGxsMsgMetaData(){ clear(); diff --git a/libretroshare/src/gxs/rsgxsdata.h b/libretroshare/src/gxs/rsgxsdata.h index 2102a8254..acc0c71d8 100644 --- a/libretroshare/src/gxs/rsgxsdata.h +++ b/libretroshare/src/gxs/rsgxsdata.h @@ -99,8 +99,6 @@ public: void clear(); void operator =(const RsMsgMetaData& rMeta); - static int refcount; - //Sort data in same order than serialiser and deserializer RsGxsGroupId mGroupId; RsGxsMessageId mMsgId; diff --git a/libretroshare/src/gxs/rsgxsutil.h b/libretroshare/src/gxs/rsgxsutil.h index f8782d861..50e749f3a 100644 --- a/libretroshare/src/gxs/rsgxsutil.h +++ b/libretroshare/src/gxs/rsgxsutil.h @@ -111,27 +111,6 @@ typedef t_RsGxsGenericDataTemporaryMapVector RsNxsMsgDa typedef t_RsGxsGenericDataTemporaryList RsNxsGrpDataTemporaryList ; typedef t_RsGxsGenericDataTemporaryList RsNxsMsgDataTemporaryList ; -#ifdef UNUSED -template -class RsGxsMetaDataTemporaryMapVector: public std::vector -{ -public: - virtual ~RsGxsMetaDataTemporaryMapVector() - { - clear() ; - } - - virtual void clear() - { - for(typename RsGxsMetaDataTemporaryMapVector::iterator it = this->begin();it!=this->end();++it) - if(it->second != NULL) - delete it->second ; - std::vector::clear() ; - } -}; -#endif - - inline RsGxsGrpMsgIdPair getMsgIdPair(RsNxsMsg& msg) { return RsGxsGrpMsgIdPair(std::make_pair(msg.grpId, msg.msgId)); @@ -146,7 +125,7 @@ inline RsGxsGrpMsgIdPair getMsgIdPair(RsGxsMsgItem& msg) * Does message clean up based on individual group expirations first * if avialable. If not then deletion s */ -class RsGxsMessageCleanUp //: public RsThread +class RsGxsMessageCleanUp { public: @@ -166,11 +145,6 @@ public: */ bool clean(); - /*! - * TODO: Rather than manual progressions consider running through a thread - */ - //virtual void data_tick(){} - private: RsGeneralDataService* const mDs; diff --git a/tests/unittests/libretroshare/gxs/common/data_support.cc b/tests/unittests/libretroshare/gxs/common/data_support.cc index bad481de9..332dcd128 100644 --- a/tests/unittests/libretroshare/gxs/common/data_support.cc +++ b/tests/unittests/libretroshare/gxs/common/data_support.cc @@ -146,7 +146,6 @@ void init_item(RsGxsMsgMetaData* metaMsg) init_random(metaMsg->mGroupId) ; init_random(metaMsg->mMsgId) ; - metaMsg->refcount = 1; init_random(metaMsg->mThreadId) ; init_random(metaMsg->mParentId) ; init_random(metaMsg->mOrigMsgId) ; From 4a81f7f5db72a9b03b3bd4183ee209a8ae277e0e Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 1 Sep 2020 15:36:47 +0200 Subject: [PATCH 20/21] Remove documentation for param which doesn't exists anymore --- libretroshare/src/retroshare/rsevents.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libretroshare/src/retroshare/rsevents.h b/libretroshare/src/retroshare/rsevents.h index 65e0e8557..2498a7712 100644 --- a/libretroshare/src/retroshare/rsevents.h +++ b/libretroshare/src/retroshare/rsevents.h @@ -195,8 +195,6 @@ public: /** * @brief Post event to the event queue. * @param[in] event - * @param[out] errorMessage Optional storage for error messsage, meaningful - * only on failure. * @return Success or error details. */ virtual std::error_condition postEvent( @@ -206,8 +204,6 @@ public: * @brief Send event directly to handlers. Blocking API * The handlers get exectuded on the caller thread. * @param[in] event - * @param[out] errorMessage Optional storage for error messsage, meaningful - * only on failure. * @return Success or error details. */ virtual std::error_condition sendEvent( From 06d8476120ba0762c8e9104e4f33d24989cd947c Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 1 Sep 2020 16:15:49 +0200 Subject: [PATCH 21/21] Forum add API to mark a post to be kept forever This way the post never get deleted even when older then parent group maximum storage time --- libretroshare/src/gxs/rsgenexchange.cc | 2 +- libretroshare/src/gxs/rsgxsutil.cc | 2 +- libretroshare/src/retroshare/rsgxsflags.h | 3 +- libretroshare/src/retroshare/rsgxsforums.h | 15 +++++++++- libretroshare/src/services/p3gxsforums.cc | 34 ++++++++++++++++++++++ libretroshare/src/services/p3gxsforums.h | 5 ++++ 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index bd51875c8..543b50f05 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -282,7 +282,7 @@ bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta) rstime_t storageTimeLimit = meta.mPublishTs + st; - return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || st == 0 || storageTimeLimit >= time(NULL); + return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER || st == 0 || storageTimeLimit >= time(NULL); } bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token, diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index 79ae187bd..491c6e3c2 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -107,7 +107,7 @@ bool RsGxsMessageCleanUp::clean() bool remove = store_period > 0 && ((meta->mPublishTs + store_period) < now) && !have_kids; // check client does not want the message kept regardless of age - remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP); + remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER); // if not subscribed remove messages (can optimise this really) remove = remove || (grpMeta->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_NOT_SUBSCRIBED); diff --git a/libretroshare/src/retroshare/rsgxsflags.h b/libretroshare/src/retroshare/rsgxsflags.h index 261173af4..10357118a 100644 --- a/libretroshare/src/retroshare/rsgxsflags.h +++ b/libretroshare/src/retroshare/rsgxsflags.h @@ -107,7 +107,8 @@ namespace GXS_SERV { static const uint32_t GXS_MSG_STATUS_UNPROCESSED = 0x00000001; // Flags to store the read/process status of group messages. static const uint32_t GXS_MSG_STATUS_GUI_UNREAD = 0x00000002; // The actual meaning may depend on the type of service. static const uint32_t GXS_MSG_STATUS_GUI_NEW = 0x00000004; // - static const uint32_t GXS_MSG_STATUS_KEEP = 0x00000008; // + /** Do not delete message even if older then group maximum storage time */ + static const uint32_t GXS_MSG_STATUS_KEEP_FOREVER = 0x00000008; static const uint32_t GXS_MSG_STATUS_DELETE = 0x00000020; // /** END GXS Msg status flags **/ diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index 7bec23b6c..da79a03a5 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -363,12 +363,25 @@ public: * @param[in] parentId id of the post of which child posts (aka replies) * are requested. * @param[out] childPosts storage for the child posts - * @return false if something failed, true otherwhise + * @return Success or error details */ virtual std::error_condition getChildPosts( const RsGxsGroupId& forumId, const RsGxsMessageId& parentId, std::vector& childPosts ) = 0; + /** + * @brief Set keep forever flag on a post so it is not deleted even if older + * then group maximum storage time + * @jsonapi{development} + * @param[in] forumId id of the forum of which the post pertain + * @param[in] postId id of the post on which to set the flag + * @param[in] keepForever true to set the flag, false to unset it + * @return Success or error details + */ + virtual std::error_condition setPostKeepForever( + const RsGxsGroupId& forumId, const RsGxsMessageId& postId, + bool keepForever ) = 0; + /** * @brief Create forum. Blocking API. * @jsonapi{development} diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 409293831..988abb667 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -919,6 +919,9 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& setMsgStatusFlags(token, msgId, status, mask); + /* WARNING: The event may be received before the operation is completed! + * TODO: move notification to blocking method markRead(...) which wait the + * operation to complete */ if (rsEvents) { auto ev = std::make_shared(); @@ -933,6 +936,37 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& /********************************************************************************************/ /********************************************************************************************/ +std::error_condition p3GxsForums::setPostKeepForever( + const RsGxsGroupId& forumId, const RsGxsMessageId& postId, + bool keepForever ) +{ + if(forumId.isNull() || postId.isNull()) return std::errc::invalid_argument; + + uint32_t mask = GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER; + uint32_t status = keepForever ? GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER : 0; + + uint32_t token; + setMsgStatusFlags(token, RsGxsGrpMsgIdPair(forumId, postId), status, mask); + + switch(waitToken(token)) + { + case RsTokenService::PENDING: // [[fallthrough]]; + case RsTokenService::PARTIAL: return std::errc::timed_out; + case RsTokenService::COMPLETE: // [[fallthrough]]; + case RsTokenService::DONE: + { + auto ev = std::make_shared(); + ev->mForumGroupId = forumId; + ev->mForumMsgId = postId; + ev->mForumEventCode = RsForumEventCode::UPDATED_MESSAGE; + rsEvents->postEvent(ev); + return std::error_condition(); + } + case RsTokenService::CANCELLED: return std::errc::operation_canceled; + default: return std::errc::bad_message; + } +} + /* so we need the same tick idea as wiki for generating dummy forums */ diff --git a/libretroshare/src/services/p3gxsforums.h b/libretroshare/src/services/p3gxsforums.h index 39416b46d..5ddce2ea2 100644 --- a/libretroshare/src/services/p3gxsforums.h +++ b/libretroshare/src/services/p3gxsforums.h @@ -137,6 +137,11 @@ public: const RsGxsGroupId& forumId, const RsGxsMessageId& parentId, std::vector& childPosts ) override; + /// @see RsGxsForums + std::error_condition setPostKeepForever( + const RsGxsGroupId& forumId, const RsGxsMessageId& postId, + bool keepForever ); + /// implementation of rsGxsGorums /// bool getGroupData(const uint32_t &token, std::vector &groups) override;