[856dfa]: kwave / clipboard.cpp Maximize Restore History

Download this file

clipboard.cpp    121 lines (111 with data), 3.4 kB

  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
118
119
120
#include "clipboard.h"
#include "main.h"
#include "menumanager.h"
#define FLUSHCLIP 1
#define TOWINDOW 2
KWaveMenuItem clip_menus[]=
{
//internalID ,name ,type ,id ,shortcut
{0 ,"&Edit" ,KMENU ,-1 ,KSHARED},
{0 ,0 ,KSEP ,KSEP ,-1},
{FLUSHCLIP ,"&Flush Clipboard" ,KITEM ,-1 ,-1},
{0 ,"&Clipboard" ,KMENU ,-1 ,KEXCLUSIVE},
{TOWINDOW ,"&to new Window" ,KITEM ,-1 ,-1},
{0 ,0 ,KEND ,KEND ,-1},
{0 ,0 ,KEND ,KEND ,-1},
{0,0,0,0,0}
};
QList<MenuManager> clipmenulist; //list of all registered Menus
//used for appending clipboard menus
extern QList<TopWidget>*topwidget;
extern KApplication *app;
extern ClipBoard *clipboard;
//*****************************************************************************
ClipBoard::ClipBoard () {signal=0,hasmenu=false;}
//*****************************************************************************
ClipBoard::ClipBoard (MSignal *signal)
{
this->signal=signal;
if (signal) signal->setMenuManager (0); //detach from previous menu context
MenuManager *tmp=clipmenulist.first();
while (tmp)
{
tmp->appendMenus (clip_menus);
tmp=clipmenulist.next();
}
hasmenu=true;
}
//*****************************************************************************
void ClipBoard::registerMenu (MenuManager *manage)
{
if (clipmenulist.findRef(manage)<0)
{
clipmenulist.append (manage);
if (clipboard) manage->appendMenus (clip_menus);
}
}
//*****************************************************************************
void ClipBoard::unregisterMenu (MenuManager *manage)
{
clipmenulist.removeRef (manage);
}
//*****************************************************************************
void ClipBoard::appendChannel (MSignal *channel)
{
signal->appendChannel (channel);
}
//*****************************************************************************
MSignal *ClipBoard::getSignal ()
{
return signal;
}
//*****************************************************************************
int ClipBoard::getLength ()
{
return signal->getLength();
}
//*****************************************************************************
void ClipBoard::setOp (int op)
{
MenuManager *manage=clipmenulist.first();
if (manage) op=manage->translateId (clip_menus,op);
switch (op)
{
case TOWINDOW:
toWindow ();
break;
case FLUSHCLIP:
delete this;
break;
}
}
//*****************************************************************************
void ClipBoard::toWindow ()
{
if (signal)
{
TopWidget *tnew=new TopWidget(app);
topwidget->append (tnew);
tnew->setSignal (signal);
tnew->show();
tnew->setCaption (klocale->translate("Clipboard"));
signal=0; //detach signal
delete this;
}
}
//*****************************************************************************
ClipBoard::~ClipBoard ()
{
if (signal) delete signal;
if (hasmenu)
{
MenuManager *tmp=clipmenulist.first();
printf ("removing from %p\n",tmp);
while (tmp)
{
tmp->deleteMenus (clip_menus);
tmp=clipmenulist.next();
}
}
}
//*****************************************************************************