Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F621464
MyTextEditorWidget.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
MyTextEditorWidget.cpp
View Options
#include
"MyTextEditorWidget.h"
#include
"MainWindow.h"
#include
"common/misc.h"
#include
<QMenu>
#include
<QFileDialog>
#include
"common/joinpath.h"
MyTextEditorWidget
::
MyTextEditorWidget
(
QWidget
*
parent
)
:
TextEditorWidget
(
parent
)
{
}
void
MyTextEditorWidget
::
setDocument
(
const
QList
<
Document
::
Line
>
*
source
,
MainWindow
*
mw
,
QString
const
&
object_id
,
QString
const
&
object_path
)
{
this
->
mainwindow
=
mw
;
this
->
object_id
=
object_id
;
this
->
object_path
=
object_path
;
TextEditorWidget
::
setDocument
(
source
);
}
void
MyTextEditorWidget
::
contextMenuEvent
(
QContextMenuEvent
*
event
)
{
QString
id
=
object_id
;
if
(
id
.
startsWith
(
PATH_PREFIX
))
{
// pass
}
else
if
(
Git
::
isValidID
(
id
))
{
// pass
}
else
{
return
;
// invalid id
}
QMenu
menu
;
QAction
*
a_save_as
=
id
.
isEmpty
()
?
nullptr
:
menu
.
addAction
(
tr
(
"Save as..."
));
QAction
*
a_copy
=
menu
.
addAction
(
tr
(
"Copy"
));
if
(
!
menu
.
actions
().
isEmpty
())
{
update
();
QAction
*
a
=
menu
.
exec
(
misc
::
contextMenuPos
(
this
,
event
));
if
(
a
)
{
if
(
a
==
a_save_as
)
{
QString
path
=
mainwindow
->
currentWorkingCopyDir
()
/
object_path
;
QString
dstpath
=
QFileDialog
::
getSaveFileName
(
window
(),
tr
(
"Save as"
),
path
);
if
(
!
dstpath
.
isEmpty
())
{
mainwindow
->
saveAs
(
mainwindow
->
frame
(),
id
,
dstpath
);
}
update
();
return
;
}
if
(
a
==
a_copy
)
{
editCopy
();
return
;
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, Nov 14, 7:09 PM (19 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
125775
Default Alt Text
MyTextEditorWidget.cpp (1 KB)
Attached To
Mode
R77 Guitar
Attached
Detach File
Event Timeline