From db9dd0f04d1ebe00974f53c6bfadf66295e67db8 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 15 Jun 2010 11:34:58 +0000 Subject: [PATCH] added to settings for tray message enable/disable fixed to get work Export Certificate on NetworkDialog added to display on uploads extensions icons git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3137 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/NetworkDialog.cpp | 42 +++++++++---- retroshare-gui/src/gui/TransfersDialog.cpp | 60 ++++++++++++++++++- .../src/gui/settings/NotifyPage.cpp | 31 +++++----- retroshare-gui/src/gui/settings/NotifyPage.h | 2 + retroshare-gui/src/gui/settings/NotifyPage.ui | 7 --- retroshare-gui/src/main.cpp | 8 ++- 6 files changed, 111 insertions(+), 39 deletions(-) diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 9599228cb..7ae78a02b 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -662,22 +662,38 @@ void NetworkDialog::on_actionExportKey_activated() { qDebug() << " exportcert"; - QString qdir = QFileDialog::getSaveFileName(this, - "Please choose a filename", - QDir::homePath(), - "RetroShare Certificate (*.pqi)"); - - if ( rsPeers->saveCertificateToFile(rsPeers->getOwnId(), qdir.toStdString()) ) - { + std::string cert = rsPeers->saveCertificateToString(rsPeers->getOwnId()); + if (cert.empty()) { QMessageBox::information(this, tr("RetroShare"), - tr("Certificate file successfully created"), + tr("Sorry, create certificate failed"), QMessageBox::Ok, QMessageBox::Ok); + return; } - else - { - QMessageBox::information(this, tr("RetroShare"), - tr("Sorry, certificate file creation failed"), - QMessageBox::Ok, QMessageBox::Ok); + + QString qdir = QFileDialog::getSaveFileName(this, + tr("Please choose a filename"), + QDir::homePath(), + tr("RetroShare Certificate (*.rsc );;All Files (*)")); + //Todo: move save to file to p3Peers::SaveCertificateToFile + + if (qdir.isEmpty() == false) { + QFile CertFile (qdir); + if (CertFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + if (CertFile.write(QByteArray(cert.c_str())) > 0) { + QMessageBox::information(this, tr("RetroShare"), + tr("Certificate file successfully created"), + QMessageBox::Ok, QMessageBox::Ok); + } else { + QMessageBox::information(this, tr("RetroShare"), + tr("Sorry, certificate file creation failed"), + QMessageBox::Ok, QMessageBox::Ok); + } + CertFile.close(); + } else { + QMessageBox::information(this, tr("RetroShare"), + tr("Sorry, certificate file creation failed"), + QMessageBox::Ok, QMessageBox::Ok); + } } } diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index 4c1ccba81..755eee80e 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -172,7 +172,7 @@ TransfersDialog::TransfersDialog(QWidget *parent) upheader->setResizeMode (USTATUS, QHeaderView::Interactive); upheader->setResizeMode (USERNAME, QHeaderView::Interactive); - upheader->resizeSection ( UNAME, 170 ); + upheader->resizeSection ( UNAME, 190 ); upheader->resizeSection ( USIZE, 70 ); upheader->resizeSection ( UTRANSFERRED, 75 ); upheader->resizeSection ( ULSPEED, 75 ); @@ -607,6 +607,64 @@ int TransfersDialog::addUploadItem(const QString&, const QString& name, const QS ULListModel->setData(ULListModel->index(row, USTATUS), QVariant((QString)status)); ULListModel->setData(ULListModel->index(row, USERNAME), QVariant((QString)source)); ULListModel->setData(ULListModel->index(row, UHASH), QVariant((QString)coreID)); + + QString ext = QFileInfo(name).suffix(); + if (ext == "rsfc" || ext == "rsfb") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/folder16.png")), Qt::DecorationRole); + } + else if (ext == "rsrl") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/irkick.png")), Qt::DecorationRole); + } + else if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "JPG"|| ext == "png" || ext == "gif" + || ext == "bmp" || ext == "ico" || ext == "svg") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypePicture.png")), Qt::DecorationRole); + } + else if (ext == "avi" ||ext == "AVI" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "divx" || ext == "ts" + || ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov" || ext == "asf" || ext == "xvid" + || ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "mpeg" || ext == "ogm") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeVideo.png")), Qt::DecorationRole); + } + else if (ext == "ogg" || ext == "mp3" || ext == "MP3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeAudio.png")), Qt::DecorationRole); + } + else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z" || ext == "msi" + || ext == "rar" || ext == "rpm" || ext == "ace" || ext == "jar" || ext == "tgz" || ext == "lha" + || ext == "cab" || ext == "cbz"|| ext == "cbr" || ext == "alz" || ext == "sit" || ext == "arj" || ext == "deb") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeArchive.png")), Qt::DecorationRole); + } + else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com" || ext == "exe" || ext == "js" || ext == "pif" + || ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeProgram.png")), Qt::DecorationRole); + } + else if (ext == "iso" || ext == "nrg" || ext == "mdf" || ext == "img" || ext == "dmg" || ext == "bin" ) + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeCDImage.png")), Qt::DecorationRole); + } + else if (ext == "txt" || ext == "cpp" || ext == "c" || ext == "h") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole); + } + else if (ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls" || ext == "pps" || ext == "xml" + || ext == "sxc" || ext == "odt" || ext == "ods" || ext == "dot" || ext == "ppt" || ext == "css" ) + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole); + } + else if (ext == "html" || ext == "htm" || ext == "php") + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeDocument.png")), Qt::DecorationRole); + } + else + { + ULListModel->setData(ULListModel->index(row,UNAME), QIcon(QString::fromUtf8(":/images/FileTypeAny.png")), Qt::DecorationRole); + } + return row; } diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 1aaae0aa4..54dd0d91d 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -40,11 +40,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags) setAttribute(Qt::WA_QuitOnClose, false); setWindowTitle(windowTitle() + QLatin1String(" - Notify")); - //load(); - //QTimer *timer = new QTimer(this); - //timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); - //timer->start(1000); /* Hide platform specific features */ @@ -98,8 +94,6 @@ NotifyPage::save(QString &errmsg) newsflags |= RS_FEED_TYPE_CHAT; if (ui.notify_Messages->isChecked()) newsflags |= RS_FEED_TYPE_MSG; - if (ui.notify_Downloads->isChecked()) - newsflags |= RS_FEED_TYPE_FILES; if (ui.chat_NewWindow->isChecked()) chatflags |= RS_CHAT_OPEN_NEW; @@ -108,9 +102,11 @@ NotifyPage::save(QString &errmsg) if (ui.chat_Focus->isChecked()) chatflags |= RS_CHAT_FOCUS; - Settings->setNotifyFlags(notifyflags); - Settings->setNewsFeedFlags(newsflags); - Settings->setChatFlags(chatflags); + Settings->setNotifyFlags(notifyflags); + Settings->setNewsFeedFlags(newsflags); + Settings->setChatFlags(chatflags); + + Settings->setValue(QString::fromUtf8("DisplayTrayGroupChat"), trayGroupChat()); load(); return true; @@ -121,14 +117,14 @@ NotifyPage::save(QString &errmsg) void NotifyPage::load() { /* extract from rsNotify the flags */ - uint notifyflags = Settings->getNotifyFlags(); - uint newsflags = Settings->getNewsFeedFlags(); - uint chatflags = Settings->getChatFlags(); + uint notifyflags = Settings->getNotifyFlags(); + uint newsflags = Settings->getNewsFeedFlags(); + uint chatflags = Settings->getChatFlags(); ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT); ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG); ui.systray_GroupChat->setChecked(true) ; - //ui.popup_NewChat->setChecked(notifyflags & RS_POPUP_CHAT); + //ui.popup_NewChat->setChecked(notifyflags & RS_POPUP_CHAT); //ui.popup_Call->setChecked(notifyflags & RS_POPUP_CALL); ui.notify_Peers->setChecked(newsflags & RS_FEED_TYPE_PEER); @@ -137,17 +133,15 @@ void NotifyPage::load() ui.notify_Blogs->setChecked(newsflags & RS_FEED_TYPE_BLOG); ui.notify_Chat->setChecked(newsflags & RS_FEED_TYPE_CHAT); ui.notify_Messages->setChecked(newsflags & RS_FEED_TYPE_MSG); - ui.notify_Downloads->setChecked(newsflags & RS_FEED_TYPE_FILES); ui.chat_NewWindow->setChecked(chatflags & RS_CHAT_OPEN_NEW); ui.chat_Reopen->setChecked(chatflags & RS_CHAT_REOPEN); ui.chat_Focus->setChecked(chatflags & RS_CHAT_FOCUS); + ui.systray_GroupChat->setChecked(Settings->value(QString::fromUtf8("DisplayTrayGroupChat"), false).toBool()); /* disable ones that don't work yet */ ui.notify_Chat->setEnabled(false); - ui.notify_Downloads->setEnabled(false); - ui.systray_GroupChat->setEnabled(false); //ui.popup_NewChat->setEnabled(false); } @@ -158,5 +152,8 @@ void NotifyPage::updateStatus() } - +bool NotifyPage::trayGroupChat() const { + if(ui.systray_GroupChat->isChecked()) return true; + return ui.systray_GroupChat->isChecked(); +} diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index 4a99e14d2..d4b803d68 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -42,6 +42,8 @@ class NotifyPage : public ConfigPage bool save(QString &errmsg); /** Loads the settings for this page */ void load(); + + bool trayGroupChat() const; public slots: void updateStatus(); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui index 13317a999..ee2572b5f 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.ui +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -558,13 +558,6 @@ - - - - Downloads - - - diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 6f1dc5c49..e675e1170 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -172,7 +172,13 @@ int main(int argc, char *argv[]) QObject::connect(ConfCertDialog::instance(),SIGNAL(configChanged()),w->networkDialog,SLOT(insertConnect())) ; QObject::connect(w->peersDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ; - QObject::connect(w->peersDialog,SIGNAL(notifyGroupChat(const QString&,const QString&)),w,SLOT(displaySystrayMsg(const QString&,const QString&)),Qt::QueuedConnection) ; + + { + if(Settings->value(QString::fromUtf8("DisplayTrayGroupChat"), true).toBool()) + { + QObject::connect(w->peersDialog,SIGNAL(notifyGroupChat(const QString&,const QString&)),w,SLOT(displaySystrayMsg(const QString&,const QString&)),Qt::QueuedConnection) ; + } + } QObject::connect(w->messengerWindow,SIGNAL(startChat(QTreeWidgetItem* )),w->peersDialog,SLOT(chatfriend(QTreeWidgetItem* ))) ; QObject::connect(w->idle, SIGNAL(secondsIdle(int)), w->messengerWindow, SLOT(checkAndSetIdle(int)));