1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/***************************************************************************
sq_navigatordropmenu.cpp - description
-------------------
begin : ??? Feb 23 2005
copyright : (C) 2005 by Baryshev Dmitry
email : ksquirrel.iv@gmail.com
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tdelocale.h>
#include <tdeaction.h>
#include <tdeio/job.h>
#include <kstringhandler.h>
#include "ksquirrel.h"
#include "sq_popupmenu.h"
#include "sq_navigatordropmenu.h"
SQ_NavigatorDropMenu * SQ_NavigatorDropMenu::m_instance= 0;
SQ_NavigatorDropMenu::SQ_NavigatorDropMenu(TQObject *parent) : TQObject(parent)
{
m_instance = this;
TDEActionCollection *ac = new TDEActionCollection(0, this, "Actions for drop menu");
dropmenu = new SQ_PopupMenu(0);
// "copy" action
TDEAction *pACopy = new TDEAction(i18n("Copy here"), "edit-paste", 0, this, TQT_SLOT(slotCopy()), ac, "sq_copy");
// "move" action
TDEAction *pAMove = new TDEAction(i18n("Move here"), 0, 0, this, TQT_SLOT(slotMove()), ac, "sq_move");
// "link" action
TDEAction *pALink = new TDEAction(i18n("Link here"), "www", 0, this, TQT_SLOT(slotLink()), ac, "sq_link");
// "cancel" action, this action will do nothing - just close popup menu
TDEAction *pACancel = new TDEAction(i18n("Cancel"), 0, 0, 0, 0, ac, "sq_cancel");
// plug all actions to popup menu
dropmenu->insertTitle(TQString());
pACopy->plug(dropmenu);
pAMove->plug(dropmenu);
pALink->plug(dropmenu);
dropmenu->insertSeparator();
pACancel->plug(dropmenu);
}
SQ_NavigatorDropMenu::~SQ_NavigatorDropMenu()
{
delete dropmenu;
}
void SQ_NavigatorDropMenu::slotCopy()
{
if(also) emit done(url, SQ_NavigatorDropMenu::Copy);
TDEIO::Job *job = TDEIO::copy(list, url);
connect(job, TQT_SIGNAL(result(TDEIO::Job *)), this, TQT_SLOT(slotJobResult(TDEIO::Job *)));
}
void SQ_NavigatorDropMenu::slotMove()
{
if(also) emit done(url, SQ_NavigatorDropMenu::Move);
TDEIO::Job *job = TDEIO::move(list, url);
connect(job, TQT_SIGNAL(result(TDEIO::Job *)), this, TQT_SLOT(slotJobResult(TDEIO::Job *)));
}
void SQ_NavigatorDropMenu::slotLink()
{
if(also) emit done(url, SQ_NavigatorDropMenu::Link);
TDEIO::Job *job = TDEIO::link(list, url);
connect(job, TQT_SIGNAL(result(TDEIO::Job *)), this, TQT_SLOT(slotJobResult(TDEIO::Job *)));
}
void SQ_NavigatorDropMenu::slotJobResult(TDEIO::Job *job)
{
if(job && job->error())
job->showErrorDialog(KSquirrel::app());
}
/*
* Save destination url and urls of dropped files.
*/
void SQ_NavigatorDropMenu::setupFiles(const KURL::List &l, const KURL &u)
{
list = l;
url = u;
dropmenu->changeTitle(KStringHandler::lsqueeze(u.isLocalFile() ? u.path() : u.prettyURL(), 20));
}
/*
* Show popup menu with available actions.
*/
void SQ_NavigatorDropMenu::exec(const TQPoint &pos, bool _also)
{
also = _also;
dropmenu->exec(pos);
}
#include "sq_navigatordropmenu.moc"
|