Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/filesharingmanager.cpp b/src/filesharingmanager.cpp
- index 508e75af..1f5a6653 100644
- --- a/src/filesharingmanager.cpp
- +++ b/src/filesharingmanager.cpp
- @@ -300,3 +300,14 @@ QList<FileSharingItem*> FileSharingManager::fromMimeData(const QMimeData *data,
- return ret;
- }
- +QList<FileSharingItem*> FileSharingManager::fromFilesList(const QStringList &fileList, PsiAccount *acc)
- +{
- + QList<FileSharingItem*> ret;
- + if(fileList.isEmpty())
- + return ret;
- + foreach (const QString &file, fileList) {
- + auto item = new FileSharingItem(file, acc, this);
- + ret << item;
- + }
- + return ret;
- +}
- diff --git a/src/filesharingmanager.h b/src/filesharingmanager.h
- index c8880e5f..00000857 100644
- --- a/src/filesharingmanager.h
- +++ b/src/filesharingmanager.h
- @@ -84,6 +84,7 @@ public:
- FileCacheItem *getCacheItem(const QString &id, bool reborn = false);
- FileCacheItem *saveToCache(const QString &id, const QByteArray &data, const QVariantMap &metadata, unsigned int maxAge);
- QList<FileSharingItem *> fromMimeData(const QMimeData *data, PsiAccount *acc);
- + QList<FileSharingItem *> fromFilesList(const QStringList &fileList, PsiAccount *acc);
- signals:
- public slots:
- diff --git a/src/groupchatdlg.cpp b/src/groupchatdlg.cpp
- index 53d9da5c..b1c63533 100644
- --- a/src/groupchatdlg.cpp
- +++ b/src/groupchatdlg.cpp
- @@ -97,6 +97,7 @@
- #include "filesharedlg.h"
- #include "filesharingmanager.h"
- #include "tabdlg.h"
- +#include "fileutil.h"
- #ifdef Q_OS_WIN
- #include <windows.h>
- @@ -925,9 +926,37 @@ GCMainDlg::GCMainDlg(PsiAccount *pa, const Jid &j, TabManager *tabManager)
- else if (name == QLatin1String("gchat_templates")) {
- action->setMenu(getTemplateMenu());
- }
- - else if (name == "gchat_pin_tab" || name == "gchat_unpin_tab") {
- + else if (name == "gchat_share_files") {
- + connect(action, &QAction::triggered, this, [this](){
- + QStringList files = FileUtil::getOpenFileNames(this, tr("Open Files For Sharing"));
- + if(files.isEmpty())
- + return;
- +
- + FileSharingManager *fManager = new FileSharingManager(this);
- + auto itList = fManager->fromFilesList(files, account());
- + auto dlg = new FileShareDlg(itList, this);
- +
- + connect(dlg, &FileShareDlg::published, this, [this, dlg](){
- + FileSharingItem *item;
- + while ((item = dlg->takePendingPublisher())) {
- + Message m(jid());
- + m.setType("groupchat");
- + if (item->setupMessage(m)) {
- + aSend(m);
- + }
- + }
- + });
- +
- + dlg->show();
- +
- + });
- + }
- + else if (name == "gchat_pin_tab") {
- connect(action, SIGNAL(triggered()), SLOT(pinTab()));
- }
- + else if (name == "gchat_unpin_tab") {
- + connect(action, SIGNAL(triggered()), SLOT(unpinTab()));
- + }
- }
- actList = account()->psi()->actionList()->actionLists(PsiActionList::Actions_Common).at(0);
- diff --git a/src/psiactionlist.cpp b/src/psiactionlist.cpp
- index 106e7eea..f801e13d 100644
- --- a/src/psiactionlist.cpp
- +++ b/src/psiactionlist.cpp
- @@ -456,6 +456,7 @@ void PsiActionList::Private::createChat()
- IconAction *actTemplates = new IconAction(tr("Templates"), "psi/action_templates", tr("Templates"), 0, this);
- IconAction *actPinTab = new IconAction(tr("Pin Tab"), "psi/pin", tr("Pin Tab"), 0 , this);
- IconAction *actUnpinTab = new IconAction(tr("Unpin Tab"), "psi/pin", tr("Unpin Tab"), 0 , this);
- + IconAction *actShareFiles = new IconAction(tr("Share Files"), "psi/filemanager", tr("Share Files"), 0, this);
- ActionNames actions[] = {
- { "chat_clear", actClear },
- @@ -471,6 +472,7 @@ void PsiActionList::Private::createChat()
- { "chat_compact", actCompact },
- { "chat_active_contacts", actActiveContacts },
- { "chat_templates", actTemplates },
- + { "chat_share_files", actShareFiles},
- { "chat_pin_tab", actPinTab },
- { "chat_unpin_tab", actUnpinTab },
- { "", nullptr }
- @@ -493,6 +495,7 @@ void PsiActionList::Private::createGroupchat()
- IconAction *actTemplates = new IconAction(tr("Templates"), "psi/action_templates", tr("Templates"), 0, this);
- IconAction *actPinTab = new IconAction(tr("Pin Tab"), "psi/pin", tr("Pin Tab"), 0 , this);
- IconAction *actUnpinTab = new IconAction(tr("Unpin Tab"), "psi/pin", tr("Unpin Tab"), 0 , this);
- + IconAction *actShareFiles = new IconAction(tr("Share Files"), "psi/filemanager", tr("Share Files"), 0, this);
- ActionNames actions[] = {
- { "gchat_clear", actClear },
- @@ -501,6 +504,7 @@ void PsiActionList::Private::createGroupchat()
- { "gchat_configure", actConfigure },
- { "gchat_icon", actIcon },
- { "gchat_templates", actTemplates },
- + { "gchat_share_files", actShareFiles},
- { "gchat_pin_tab", actPinTab },
- { "gchat_unpin_tab", actUnpinTab },
- { "", nullptr }
- diff --git a/src/psichatdlg.cpp b/src/psichatdlg.cpp
- index e7a40ed4..33a2613c 100644
- --- a/src/psichatdlg.cpp
- +++ b/src/psichatdlg.cpp
- @@ -50,8 +50,10 @@
- #include "actionlist.h"
- #include "psiactionlist.h"
- #include "tabdlg.h"
- -#ifdef PSI_PLUGINS
- +#include "fileutil.h"
- #include "filesharedlg.h"
- +#include "filesharingmanager.h"
- +#ifdef PSI_PLUGINS
- #include "pluginmanager.h"
- #endif
- @@ -549,9 +551,37 @@ void PsiChatDlg::initToolButtons()
- else if (name == "chat_templates") {
- action->setMenu(getTemplateMenu());
- }
- - else if (name == "chat_pin_tab" || name == "chat_unpin_tab") {
- + else if (name == "chat_share_files") {
- + connect(action, &QAction::triggered, this, [this](){
- + QStringList files = FileUtil::getOpenFileNames(this, tr("Open Files For Sharing"));
- + if(files.isEmpty())
- + return;
- +
- + FileSharingManager *fManager = new FileSharingManager(this);
- + auto itList = fManager->fromFilesList(files, account());
- + auto dlg = new FileShareDlg(itList, this);
- +
- + connect(dlg, &FileShareDlg::published, this, [this, dlg](){
- + FileSharingItem *item;
- + while ((item = dlg->takePendingPublisher())) {
- + Message m(jid());
- + m.setType("chat");
- + if (item->setupMessage(m)) {
- + aSend(m);
- + }
- + }
- + });
- +
- + dlg->show();
- +
- + });
- + }
- + else if (name == "chat_pin_tab") {
- connect(action, SIGNAL(triggered()), SLOT(pinTab()));
- }
- + else if (name == "chat_unpin_tab") {
- + connect(action, SIGNAL(triggered()), SLOT(unpinTab()));
- + }
- }
- list = account()->psi()->actionList()->actionLists(PsiActionList::Actions_Common).at(0);
- diff --git a/src/tabs/tabbablewidget.cpp b/src/tabs/tabbablewidget.cpp
- index 34f16422..4a0bfc90 100644
- --- a/src/tabs/tabbablewidget.cpp
- +++ b/src/tabs/tabbablewidget.cpp
- @@ -42,7 +42,7 @@ TabbableWidget::TabbableWidget(const Jid &jid, PsiAccount *pa, TabManager *tabMa
- , tabManager_(tabManager)
- {
- if (TabbableWidget::chatsCount == 0) {
- - TabbableWidget::templateMenu = new SendButtonTemplatesMenu(NULL);
- + TabbableWidget::templateMenu = new SendButtonTemplatesMenu(nullptr);
- TabbableWidget::templateMenu->setParams(false);
- TabbableWidget::templateMenu->setStyleSheet(PsiOptions::instance()->getOption("options.ui.chat.css").toString());
- }
- @@ -124,20 +124,20 @@ TabbableWidget::~TabbableWidget()
- }
- --TabbableWidget::chatsCount;
- if (TabbableWidget::chatsCount == 0) {
- - if (TabbableWidget::templateMenu != NULL) {
- + if (TabbableWidget::templateMenu != nullptr) {
- delete TabbableWidget::templateMenu;
- - TabbableWidget::templateMenu = NULL;
- + TabbableWidget::templateMenu = nullptr;
- }
- if (!TabbableWidget::templateEditDlg.isNull()) {
- delete (TabbableWidget::templateEditDlg);
- - TabbableWidget::templateEditDlg = NULL;
- + TabbableWidget::templateEditDlg = nullptr;
- }
- }
- }
- int TabbableWidget::chatsCount = 0;
- -SendButtonTemplatesMenu *TabbableWidget::templateMenu = NULL;
- -QPointer<SendButtonTemplatesEditor> TabbableWidget::templateEditDlg = NULL;
- +SendButtonTemplatesMenu *TabbableWidget::templateMenu = nullptr;
- +QPointer<SendButtonTemplatesEditor> TabbableWidget::templateEditDlg = nullptr;
- SendButtonTemplatesMenu* TabbableWidget::getTemplateMenu()
- {
- @@ -298,3 +298,8 @@ void TabbableWidget::pinTab()
- {
- getManagingTabDlg()->pinTab(this);
- }
- +
- +void TabbableWidget::unpinTab()
- +{
- + getManagingTabDlg()->unpinTab(this);
- +}
- diff --git a/src/tabs/tabbablewidget.h b/src/tabs/tabbablewidget.h
- index a2084748..2f82e237 100644
- --- a/src/tabs/tabbablewidget.h
- +++ b/src/tabs/tabbablewidget.h
- @@ -88,6 +88,7 @@ public slots:
- virtual void ensureTabbedCorrectly();
- void hideTab();
- void pinTab();
- + void unpinTab();
- protected:
- virtual void setJid(const Jid&);
- diff --git a/src/tabs/tabdlg.cpp b/src/tabs/tabdlg.cpp
- index c76e7cde..a6a2075b 100644
- --- a/src/tabs/tabdlg.cpp
- +++ b/src/tabs/tabdlg.cpp
- @@ -273,9 +273,14 @@ void TabDlg::showTabMenu(int tab, QPoint pos, QContextMenuEvent * event)
- tabMenu_->addMenu(sendTo);
- }
- - QAction *p = 0;
- + QAction *p = nullptr, *up = nullptr;
- if (PsiOptions::instance()->getOption("options.ui.tabs.multi-rows", true).toBool()) {
- - p = tabMenu_->addAction(tabWidget_->isPagePinned(getTab(tab)) ? tr("Unpin Tab") : tr("Pin Tab"));
- + if (tabWidget_->isPagePinned(getTab(tab))) {
- + up = tabMenu_->addAction(tr("Unpin Tab"));
- + }
- + else{
- + p = tabMenu_->addAction(tr("Pin Tab"));
- + }
- }
- QAction *act = tabMenu_->exec(pos);
- @@ -293,6 +298,9 @@ void TabDlg::showTabMenu(int tab, QPoint pos, QContextMenuEvent * event)
- else if (p && act == p) {
- pinTab(getTab(tab));
- }
- + else if (up && act == up) {
- + unpinTab(getTab(tab));
- + }
- else {
- TabDlg* target = sentTos[act];
- if (target)
- @@ -385,7 +393,7 @@ void TabDlg::setLooks()
- void TabDlg::tabSelected(QWidget* _selected)
- {
- // _selected could be null when TabDlg is closing and deleting all its tabs
- - TabbableWidget* selected = _selected ? qobject_cast<TabbableWidget*>(_selected) : 0;
- + TabbableWidget* selected = _selected ? qobject_cast<TabbableWidget*>(_selected) : nullptr;
- if (!selectedTab_.isNull()) {
- QCoreApplication::postEvent(selectedTab_, new QEvent(QEvent::ActivationChange));
- }
- @@ -440,9 +448,19 @@ void TabDlg::hideTab(TabbableWidget* tab)
- void TabDlg::pinTab(TabbableWidget* tab)
- {
- - tabWidget_->setPagePinned(tab, !tabWidget_->isPagePinned(tab));
- + if(!tabWidget_->isPagePinned(tab)) {
- + tabWidget_->setPagePinned(tab, true);
- + }
- }
- +void TabDlg::unpinTab(TabbableWidget* tab)
- +{
- + if(tabWidget_->isPagePinned(tab)) {
- + tabWidget_->setPagePinned(tab, false);
- + }
- +}
- +
- +
- void TabDlg::hideAllTab()
- {
- foreach(TabbableWidget* tab, tabs_)
- diff --git a/src/tabs/tabdlg.h b/src/tabs/tabdlg.h
- index 3652d82b..a861bf39 100644
- --- a/src/tabs/tabdlg.h
- +++ b/src/tabs/tabdlg.h
- @@ -126,6 +126,7 @@ public slots:
- void tabCloseRequested(int i);
- void hideTab(TabbableWidget*);
- void pinTab(TabbableWidget *tab);
- + void unpinTab(TabbableWidget *tab);
- void hideCurrentTab();
- void hideAllTab();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement