mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 17:09:34 -05:00
Ported patch from thunder2 (http://sourceforge.net/tracker/index.php?func=detail&aid=2991827&group_id=178712&atid=886241)
- Bug fix: Checkbox for automatic share of the incoming directory doesn't correctly set with setDown, use setChecked - ShareManager and RSettingsWin doesn't need to be created all the time - RSettingsWin: Save the last active page for the current runtime - ShareManager and DirectoryPage: Show changed shared directories direct after the change git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2777 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
900ae2332f
commit
0773e92f85
@ -788,16 +788,16 @@ void FileIndexMonitor::getSharedDirectories(std::list<SharedDirInfo> &dirs)
|
||||
RsStackMutex stack(fiMutex) ; /* LOCKED DIRS */
|
||||
|
||||
/* must provide pendingDirs, as other parts depend on instanteous response */
|
||||
// if (pendingDirs)
|
||||
// dirs = pendingDirList;
|
||||
// else
|
||||
// {
|
||||
if (pendingDirs)
|
||||
dirs = pendingDirList;
|
||||
else
|
||||
{
|
||||
/* get actual list (not pending stuff) */
|
||||
std::map<std::string, SharedDirInfo>::const_iterator it;
|
||||
|
||||
for(it = directoryMap.begin(); it != directoryMap.end(); it++)
|
||||
dirs.push_back(it->second) ;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -402,6 +402,14 @@ void MainWindow::updateHashingInfo(const QString& s)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::postModDirectories(bool update_local)
|
||||
{
|
||||
RSettingsWin::postModDirectories(update_local);
|
||||
ShareManager::postModDirectories(update_local);
|
||||
|
||||
QCoreApplication::flush();
|
||||
}
|
||||
|
||||
/** Creates a new action associated with a config page. */
|
||||
QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
|
||||
{
|
||||
@ -451,7 +459,7 @@ void MainWindow::addFriend()
|
||||
/** Shows Share Manager */
|
||||
void MainWindow::openShareManager()
|
||||
{
|
||||
ShareManager::showYourself();
|
||||
ShareManager::showYourself();
|
||||
}
|
||||
|
||||
|
||||
@ -466,11 +474,7 @@ MainWindow::showMess(MainWindow::Page page)
|
||||
/** Shows Options */
|
||||
void MainWindow::showSettings()
|
||||
{
|
||||
static RSettingsWin *win = new RSettingsWin(this);
|
||||
if (win->isHidden())
|
||||
win->setNewPage(0);
|
||||
win->show();
|
||||
win->activateWindow();
|
||||
RSettingsWin::showYourself(this);
|
||||
}
|
||||
|
||||
/** Shows Messenger window */
|
||||
@ -624,8 +628,8 @@ void MainWindow::loadStyleSheet(const QString &sheetName)
|
||||
|
||||
void MainWindow::showabout()
|
||||
{
|
||||
static AboutDialog *adlg = new AboutDialog(this);
|
||||
adlg->exec();
|
||||
AboutDialog adlg(this);
|
||||
adlg.exec();
|
||||
}
|
||||
|
||||
/** Displays the help browser and displays the most recently viewed help
|
||||
@ -647,8 +651,8 @@ void MainWindow::showHelpDialog(const QString &topic)
|
||||
|
||||
void MainWindow::on_actionQuick_Start_Wizard_activated()
|
||||
{
|
||||
QuickStartWizard *qstartwizard = new QuickStartWizard(this);
|
||||
qstartwizard->exec();
|
||||
QuickStartWizard qstartwizard(this);
|
||||
qstartwizard.exec();
|
||||
}
|
||||
|
||||
/** Called when the user changes the UI translation. */
|
||||
|
@ -104,7 +104,8 @@ public slots:
|
||||
|
||||
void updateHashingInfo(const QString&) ;
|
||||
void displayErrorMessage(int,int,const QString&) ;
|
||||
|
||||
void postModDirectories(bool update_local);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
|
@ -47,6 +47,8 @@ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags)
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
isLoading = false;
|
||||
load();
|
||||
|
||||
connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( showShareDialog() ) );
|
||||
connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) );
|
||||
@ -57,20 +59,23 @@ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags)
|
||||
ui.addButton->setToolTip(tr("Add a Share Directory"));
|
||||
ui.removeButton->setToolTip(tr("Stop sharing selected Directory"));
|
||||
|
||||
load();
|
||||
|
||||
ui.shareddirList->horizontalHeader()->setResizeMode( 0,QHeaderView::Stretch);
|
||||
ui.shareddirList->horizontalHeader()->setResizeMode( 2,QHeaderView::Interactive);
|
||||
|
||||
ui.shareddirList->horizontalHeader()->resizeSection( 0, 360 );
|
||||
ui.shareddirList->horizontalHeader()->setStretchLastSection(false);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
}
|
||||
|
||||
ShareManager::~ShareManager()
|
||||
{
|
||||
_instance = NULL;
|
||||
}
|
||||
|
||||
void ShareManager::shareddirListCostumPopupMenu( QPoint point )
|
||||
{
|
||||
|
||||
QMenu contextMnu( this );
|
||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||
|
||||
@ -86,6 +91,7 @@ void ShareManager::shareddirListCostumPopupMenu( QPoint point )
|
||||
/** Loads the settings for this page */
|
||||
void ShareManager::load()
|
||||
{
|
||||
isLoading = true;
|
||||
std::cerr << "ShareManager:: In load !!!!!" << std::endl ;
|
||||
|
||||
std::list<SharedDirInfo>::const_iterator it;
|
||||
@ -95,16 +101,21 @@ void ShareManager::load()
|
||||
/* get a link to the table */
|
||||
QTableWidget *listWidget = ui.shareddirList;
|
||||
|
||||
/* remove old items ??? */
|
||||
listWidget->clearContents() ;
|
||||
listWidget->setRowCount(0) ;
|
||||
/* set new row count */
|
||||
listWidget->setRowCount(dirs.size());
|
||||
|
||||
connect(this,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(updateFlags(QTableWidgetItem*))) ;
|
||||
|
||||
#ifndef USE_COMBOBOX
|
||||
QString ToolTips [2] = { QString("If checked, the share is anonymously shared to anybody."),
|
||||
QString("If checked, the share is browsable by your friends.") };
|
||||
int Flags [2] = { RS_FILE_HINTS_NETWORK_WIDE, RS_FILE_HINTS_BROWSABLE };
|
||||
#endif
|
||||
|
||||
|
||||
int row=0 ;
|
||||
for(it = dirs.begin(); it != dirs.end(); it++,++row)
|
||||
{
|
||||
listWidget->insertRow(row) ;
|
||||
listWidget->setItem(row,0,new QTableWidgetItem(QString::fromUtf8((*it).filename.c_str())));
|
||||
#ifdef USE_COMBOBOX
|
||||
QComboBox *cb = new QComboBox ;
|
||||
@ -136,20 +147,19 @@ void ShareManager::load()
|
||||
|
||||
cb->setCurrentIndex(index) ;
|
||||
#else
|
||||
QCheckBox *cb1 = new QCheckBox ;
|
||||
QCheckBox *cb2 = new QCheckBox ;
|
||||
int col;
|
||||
for (col = 1; col <= 2; col++) {
|
||||
QModelIndex index = listWidget->model()->index(row, col, QModelIndex());
|
||||
QCheckBox *cb = (QCheckBox*) listWidget->indexWidget(index);
|
||||
if (cb == NULL) {
|
||||
cb = new QCheckBox;
|
||||
cb->setToolTip(ToolTips [col - 1]);
|
||||
listWidget->setCellWidget(row, col, cb);
|
||||
|
||||
cb1->setChecked( (*it).shareflags & RS_FILE_HINTS_NETWORK_WIDE ) ;
|
||||
cb2->setChecked( (*it).shareflags & RS_FILE_HINTS_BROWSABLE ) ;
|
||||
|
||||
cb1->setToolTip(QString("If checked, the share is anonymously shared to anybody.")) ;
|
||||
cb2->setToolTip(QString("If checked, the share is browsable by your friends.")) ;
|
||||
|
||||
listWidget->setCellWidget(row,1,cb1);
|
||||
listWidget->setCellWidget(row,2,cb2);
|
||||
|
||||
QObject::connect(cb1,SIGNAL(toggled(bool)),this,SLOT(updateFlags(bool))) ;
|
||||
QObject::connect(cb2,SIGNAL(toggled(bool)),this,SLOT(updateFlags(bool))) ;
|
||||
QObject::connect(cb, SIGNAL(toggled(bool)), this, SLOT(updateFlags(bool))) ;
|
||||
}
|
||||
cb->setChecked((*it).shareflags & Flags [col - 1]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -157,6 +167,8 @@ void ShareManager::load()
|
||||
|
||||
listWidget->update(); /* update display */
|
||||
update();
|
||||
|
||||
isLoading = false ;
|
||||
}
|
||||
|
||||
void ShareManager::showYourself()
|
||||
@ -165,8 +177,22 @@ void ShareManager::showYourself()
|
||||
_instance = new ShareManager(NULL,0) ;
|
||||
|
||||
_instance->show() ;
|
||||
_instance->activateWindow();
|
||||
}
|
||||
|
||||
/*static*/ void ShareManager::postModDirectories(bool update_local)
|
||||
{
|
||||
if (_instance == NULL || _instance->isHidden()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (update_local) {
|
||||
_instance->load();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShareManager::addShareDirectory()
|
||||
{
|
||||
|
||||
@ -193,6 +219,9 @@ void ShareManager::addShareDirectory()
|
||||
|
||||
void ShareManager::updateFlags(bool b)
|
||||
{
|
||||
if(isLoading)
|
||||
return ;
|
||||
|
||||
std::cerr << "Updating flags (b=" << b << ") !!!" << std::endl ;
|
||||
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
|
@ -34,11 +34,13 @@ class ShareManager : public QDialog
|
||||
|
||||
public:
|
||||
static void showYourself() ;
|
||||
static void postModDirectories(bool update_local);
|
||||
|
||||
private:
|
||||
/** Default constructor */
|
||||
ShareManager( QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
~ShareManager();
|
||||
|
||||
/** Loads the settings for this page */
|
||||
void load();
|
||||
@ -65,7 +67,8 @@ private slots:
|
||||
private:
|
||||
|
||||
|
||||
static ShareManager *_instance ;
|
||||
static ShareManager *_instance;
|
||||
bool isLoading;
|
||||
|
||||
/** Define the popup menus for the Context menu */
|
||||
QMenu* contextMnu;
|
||||
|
@ -35,11 +35,6 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags)
|
||||
|
||||
//load();
|
||||
|
||||
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
|
||||
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
|
||||
connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(shareDownloadDirectory(int)));
|
||||
connect(ui.editButton, SIGNAL(clicked()), this, SLOT(editDirectories()));
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
ui.addButton->setToolTip(tr("Add a Share Directory"));
|
||||
ui.removeButton->setToolTip(tr("Remove Shared Directory"));
|
||||
@ -50,13 +45,18 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WFlags flags)
|
||||
|
||||
if (rsFiles->getShareDownloadDirectory())
|
||||
{
|
||||
ui.checkBox->setDown(true); /* signal not emitted */
|
||||
ui.checkBox->setChecked(true); /* signal not emitted */
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.checkBox->setDown(false); /* signal not emitted */
|
||||
ui.checkBox->setChecked(false); /* signal not emitted */
|
||||
}
|
||||
|
||||
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
|
||||
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
|
||||
connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(shareDownloadDirectory(int)));
|
||||
connect(ui.editButton, SIGNAL(clicked()), this, SLOT(editDirectories()));
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
@ -118,6 +118,9 @@ void DirectoriesPage::load()
|
||||
/* get a link to the table */
|
||||
QListWidget *listWidget = ui.dirList;
|
||||
|
||||
/* save current index */
|
||||
QModelIndex rootIndex = listWidget->rootIndex();
|
||||
|
||||
/* remove old items ??? */
|
||||
listWidget->clear();
|
||||
|
||||
@ -127,6 +130,9 @@ void DirectoriesPage::load()
|
||||
listWidget->addItem(QString::fromStdString((*it).filename));
|
||||
}
|
||||
|
||||
/* set saved index */
|
||||
listWidget->setCurrentIndex(rootIndex);
|
||||
|
||||
ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
|
||||
ui.partialsDir->setText(QString::fromStdString(rsFiles->getPartialsDirectory()));
|
||||
|
||||
|
@ -35,11 +35,14 @@
|
||||
|
||||
#include "rsettingswin.h"
|
||||
|
||||
RSettingsWin *RSettingsWin::_instance = NULL;
|
||||
int RSettingsWin::lastPage = 0;
|
||||
|
||||
RSettingsWin::RSettingsWin(QWidget * parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags)
|
||||
{
|
||||
setupUi(this);
|
||||
setAttribute(Qt::WA_QuitOnClose, false);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
setModal(false);
|
||||
|
||||
initStackedWidget();
|
||||
@ -48,12 +51,47 @@ RSettingsWin::RSettingsWin(QWidget * parent, Qt::WFlags flags)
|
||||
connect(okButton, SIGNAL(clicked( bool )), this, SLOT( saveChanges()) );
|
||||
}
|
||||
|
||||
RSettingsWin::~RSettingsWin()
|
||||
{
|
||||
lastPage = stackedWidget->currentIndex ();
|
||||
_instance = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
RSettingsWin::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
/*static*/ void RSettingsWin::showYourself(QWidget *parent)
|
||||
{
|
||||
if(_instance == NULL) {
|
||||
_instance = new RSettingsWin(parent);
|
||||
}
|
||||
|
||||
if (_instance->isHidden()) {
|
||||
_instance->setNewPage(lastPage);
|
||||
}
|
||||
_instance->show();
|
||||
_instance->activateWindow();
|
||||
}
|
||||
|
||||
/*static*/ void RSettingsWin::postModDirectories(bool update_local)
|
||||
{
|
||||
if (_instance == NULL || _instance->isHidden() || _instance->stackedWidget == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (update_local) {
|
||||
if (_instance->stackedWidget->currentIndex() == Directories) {
|
||||
ConfigPage *Page = (ConfigPage*) _instance->stackedWidget->currentWidget();
|
||||
if (Page) {
|
||||
Page->load();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RSettingsWin::initStackedWidget()
|
||||
{
|
||||
|
@ -34,8 +34,12 @@ class RSettingsWin: public QDialog, private Ui::Settings
|
||||
enum PageType { General = 0, Server, Transfer,
|
||||
Directories, Notify, Security, Appearance, Fileassociations, Sound };
|
||||
|
||||
static void showYourself(QWidget *parent);
|
||||
static void postModDirectories(bool update_local);
|
||||
|
||||
protected:
|
||||
RSettingsWin(QWidget * parent = 0, Qt::WFlags flags = 0);
|
||||
~RSettingsWin() {}
|
||||
~RSettingsWin();
|
||||
|
||||
public slots:
|
||||
//! Go to a specific part of the control panel.
|
||||
@ -49,6 +53,10 @@ class RSettingsWin: public QDialog, private Ui::Settings
|
||||
void loadSettings();
|
||||
void closeEvent (QCloseEvent * event);
|
||||
void initStackedWidget();
|
||||
|
||||
private:
|
||||
static RSettingsWin *_instance;
|
||||
static int lastPage;
|
||||
};
|
||||
|
||||
#endif // !RSETTINGSWIN_HPP_
|
||||
|
@ -145,6 +145,7 @@ int main(int argc, char *argv[])
|
||||
QObject::connect(notify,SIGNAL(hashingInfoChanged(const QString&)),w ,SLOT(updateHashingInfo(const QString&))) ;
|
||||
QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ;
|
||||
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ;
|
||||
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ;
|
||||
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
|
||||
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->messengerWindow ,SLOT(insertPeers() )) ;
|
||||
QObject::connect(notify,SIGNAL(friendsChanged()) ,w->peersDialog ,SLOT(insertPeers() )) ;
|
||||
|
Loading…
Reference in New Issue
Block a user