add links to cloud from shared files dialog

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1544 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
alexandrut 2009-08-17 20:19:53 +00:00
parent 43b6505512
commit 6e87a8d31f
5 changed files with 471 additions and 28 deletions

View File

@ -0,0 +1,101 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "common/vmessagebox.h"
#include "AddLinksDialog.h"
#include "rsiface/rsrank.h"
/* Images for context menu icons */
#define IMAGE_EXPORTFRIEND ":/images/exportpeers_16x16.png"
#define IMAGE_GREAT ":/images/filerating5.png"
#define IMAGE_GOOD ":/images/filerating4.png"
#define IMAGE_OK ":/images/filerating3.png"
#define IMAGE_SUX ":/images/filerating2.png"
#define IMAGE_BADLINK ":/images/filerating1.png"
/** Constructor */
AddLinksDialog::AddLinksDialog(QWidget *parent)
: QDialog(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* add button */
connect(ui.addLinkButton, SIGNAL(clicked()), this, SLOT(addLinkComment()));
connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close()));
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
int AddLinksDialog::IndexToScore(int index)
{
if ((index == -1) || (index > 4))
return 0;
int score = 2 - index;
return score;
}
void AddLinksDialog::addLinkComment()
{
/* get the title / link / comment */
QString title = ui.titleLineEdit->text();
QString link = ui.linkLineEdit->text();
QString comment = ui.linkTextEdit->toPlainText();
int32_t score = AddLinksDialog::IndexToScore(ui.scoreBox->currentIndex());
if ((link == "") || (title == ""))
{
QMessageBox::StandardButton sb = QMessageBox::warning(NULL,
"Add Link Failure",
"Missing Link and/or Title",
QMessageBox::Ok);
/* can't do anything */
return;
}
/* add it either way */
if (ui.anonBox->isChecked())
{
rsRanks->anonRankMsg("", link.toStdWString(), title.toStdWString());
}
else
{
rsRanks->newRankMsg(link.toStdWString(),
title.toStdWString(),
comment.toStdWString(), score);
}
close();
}
void AddLinksDialog::insertTitleText(std::string title)
{
ui.titleLineEdit->setText(QString::fromStdString(title));
}
void AddLinksDialog::insertLinkText(std::string link)
{
ui.linkLineEdit->setText(QString::fromStdString(link));
}

View File

@ -0,0 +1,49 @@
/****************************************************************
* RetroShare GUI is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _ADDLINKS_DIALOG_H
#define _ADDLINKS_DIALOG_H
#include "ui_AddLinksDialog.h"
class AddLinksDialog : public QDialog
{
Q_OBJECT
public:
/** Default Constructor */
AddLinksDialog(QWidget *parent = 0);
/** Default Destructor */
void insertTitleText(std::string title);
void insertLinkText(std::string link);
static int IndexToScore(int index);
public slots:
void addLinkComment();
private:
/** Qt Designer generated object */
Ui::AddLinksDialog ui;
};
#endif

View File

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddLinksDialog</class>
<widget class="QDialog" name="AddLinksDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>429</height>
</rect>
</property>
<property name="windowTitle">
<string>Add Link</string>
</property>
<property name="windowIcon">
<iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="linksiconlabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/ktorrent32.png</pixmap>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Add a new Link</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="titleLineEdit">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="4">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Url:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linkLineEdit">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="4">
<widget class="QTextEdit" name="linkTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Score:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="scoreBox">
<item>
<property name="text">
<string>+2 Great!</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating5.png</normaloff>:/images/filerating5.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>+1 Good</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating4.png</normaloff>:/images/filerating4.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>0 Okay</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating3.png</normaloff>:/images/filerating3.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>-1 Sux</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating2.png</normaloff>:/images/filerating2.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>-2 Bad Link</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating1.png</normaloff>:/images/filerating1.png</iconset>
</property>
</item>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="anonBox">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Add Anonymous Link</string>
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>196</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>375</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="closepushButton">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="addLinkButton">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Add Link</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -30,6 +30,7 @@
#include "util/RsAction.h"
#include "msgs/ChanMsgDialog.h"
#include "Preferences/rsharesettings.h"
#include "AddLinksDialog.h"
#ifndef RETROSHARE_LINK_ANALYZER
#include "RetroShareLinkAnalyzer.h"
@ -234,8 +235,6 @@ void SharedFilesDialog::downloadRemoteSelected()
QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel();
model -> downloadSelected(qism->selectedIndexes());
}
void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
@ -338,7 +337,30 @@ void SharedFilesDialog::sendLinkTo( /*std::string rsid*/ )
nMsgDialog->show();
}
void SharedFilesDialog::sendLinkToCloud()
{
copyLinkLocal ();
AddLinksDialog *nAddLinksDialog = new AddLinksDialog();
nAddLinksDialog->insertTitleText("New File");
nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString());
nAddLinksDialog->addLinkComment();
nAddLinksDialog->close();
}
void SharedFilesDialog::addLinkToCloud()
{
copyLinkLocal ();
AddLinksDialog *nAddLinksDialog = new AddLinksDialog(this);
nAddLinksDialog->insertTitleText("New File");
nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString());
nAddLinksDialog->show();
}
void SharedFilesDialog::playselectedfiles()
{
@ -591,11 +613,17 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
}
//#endif
copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) );
copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) );
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( /*std::string rsid*/ ) ) );
sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this );
connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( /*std::string rsid*/ ) ) );
sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link to Cloud" ), this );
connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud( ) ) );
addlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Add Link to Cloud" ), this );
connect( addlinkCloudAct , SIGNAL( triggered() ), this, SLOT( addLinkToCloud( ) ) );
openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this);
connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile()));
@ -607,6 +635,8 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
contextMnu2.addAction( menuAction );
contextMnu2.addAction( copylinklocalAct);
contextMnu2.addAction( sendlinkAct);
contextMnu2.addAction( sendlinkCloudAct);
contextMnu2.addAction( addlinkCloudAct);
contextMnu2.addSeparator();
contextMnu2.addAction( openfileAct);
contextMnu2.addAction( openfolderAct);
@ -704,14 +734,14 @@ void SharedFilesDialog::showFrame(bool show)
if (show) {
ui.localframe->setVisible(true);
ui.remoteframe->setVisible(false);
ui.localButton->setChecked(true);
ui.remoteButton->setChecked(false);
ui.splittedButton->setChecked(false);
ui.labeltext->setText(tr("<strong>My Shared Files</strong>"));
}
}
}
void SharedFilesDialog::showFrameRemote(bool show)
@ -719,13 +749,13 @@ void SharedFilesDialog::showFrameRemote(bool show)
if (show) {
ui.remoteframe->setVisible(true);
ui.localframe->setVisible(false);
ui.remoteButton->setChecked(true);
ui.localButton->setChecked(false);
ui.splittedButton->setChecked(false);
ui.labeltext->setText(tr("<strong>Friends Files</strong>"));
}
}
}
void SharedFilesDialog::showFrameSplitted(bool show)
@ -733,12 +763,12 @@ void SharedFilesDialog::showFrameSplitted(bool show)
if (show) {
ui.remoteframe->setVisible(true);
ui.localframe->setVisible(true);
ui.splittedButton->setChecked(true);
ui.localButton->setChecked(false);
ui.localButton->setChecked(false);
ui.remoteButton->setChecked(false);
ui.labeltext->setText(tr("<strong>Files</strong>"));
}
}
}

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
@ -33,7 +33,7 @@
#include "rsiface/rstypes.h"
#include "gui/RemoteDirModel.h"
class SharedFilesDialog : public MainPage
class SharedFilesDialog : public MainPage
{
Q_OBJECT
@ -55,9 +55,9 @@ private slots:
/** Create the context popup menu and it's submenus */
void shareddirtreeviewCostumPopupMenu( QPoint point );
void sharedDirTreeWidgetContextMenu( QPoint point );
void downloadRemoteSelected();
// void addMsgRemoteSelected();
@ -65,6 +65,8 @@ private slots:
void copyLinkLocal();
void sendLinkTo();
void sendremoteLinkTo();
void sendLinkToCloud();
void addLinkToCloud();
void showFrame(bool show);
void showFrameRemote(bool show);
@ -91,15 +93,15 @@ private:
//slots.. Maybe it's not good...
//** Define the popup menus for the Context menu */
//QMenu* contextMnu;
//QMenu* contextMnu2;
void copyLink (const QModelIndexList& lst, bool remote);
/** Defines the actions for the context menu for QTreeView */
QAction* downloadAct;
QAction* addMsgAct;
/** Defines the actions for the context menu for QTreeWidget */
QAction* openfileAct;
QAction* openfolderAct;
@ -107,8 +109,9 @@ private:
QAction* copylinklocalAct;
QAction* sendremotelinkAct;
QAction* sendlinkAct;
QAction* sendlinkCloudAct;
QAction* addlinkCloudAct;
QTreeView *shareddirtreeview;
QMovie *movie;
@ -121,7 +124,7 @@ private:
QString currentCommand;
QString currentFile;
QAction* fileAssotiationAction(const QString fileName);
};