mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-12 22:14:35 +00:00
Embedding feature patch 3: basic gui support
* lib/ui/stdmenus.inc: add menu item embedded files * src/BufferParams.cpp: set default embedded status to false * src/EmbeddedFiles.h|cpp: add a few member functions * src/frontends/qt4/Dialogs.cpp: add embedding dialog * src/frontends/qt4/GuiEmbeddedFiles.h|cpp: embedding dialog * src/frontends/qt4/ui/EmbeddedFilesUi.ui: embedding dialog * src/frontends/controllers/ControlEmbeddedFiles.h|cpp: embedding dialog control * src/frontends/qt4/Makefile.am: build system update * src/frontends/controllers/Makefile.am * development/scons/scons_manifest.py git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19953 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2607927e2f
commit
cc6fe67c35
@ -739,6 +739,7 @@ src_frontends_controllers_header_files = Split('''
|
|||||||
ControlCommand.h
|
ControlCommand.h
|
||||||
ControlCommandBuffer.h
|
ControlCommandBuffer.h
|
||||||
ControlDocument.h
|
ControlDocument.h
|
||||||
|
ControlEmbeddedFiles.h
|
||||||
ControlERT.h
|
ControlERT.h
|
||||||
ControlErrorList.h
|
ControlErrorList.h
|
||||||
ControlExternal.h
|
ControlExternal.h
|
||||||
@ -785,6 +786,7 @@ src_frontends_controllers_files = Split('''
|
|||||||
ControlCommand.cpp
|
ControlCommand.cpp
|
||||||
ControlCommandBuffer.cpp
|
ControlCommandBuffer.cpp
|
||||||
ControlDocument.cpp
|
ControlDocument.cpp
|
||||||
|
ControlEmbeddedFiles.cpp
|
||||||
ControlERT.cpp
|
ControlERT.cpp
|
||||||
ControlErrorList.cpp
|
ControlErrorList.cpp
|
||||||
ControlExternal.cpp
|
ControlExternal.cpp
|
||||||
@ -865,6 +867,7 @@ src_frontends_qt4_header_files = Split('''
|
|||||||
GuiDelimiterDialog.h
|
GuiDelimiterDialog.h
|
||||||
GuiDialogView.h
|
GuiDialogView.h
|
||||||
GuiDocument.h
|
GuiDocument.h
|
||||||
|
GuiEmbeddedFiles.h
|
||||||
GuiErrorList.h
|
GuiErrorList.h
|
||||||
GuiERT.h
|
GuiERT.h
|
||||||
GuiExternal.h
|
GuiExternal.h
|
||||||
@ -954,6 +957,7 @@ src_frontends_qt4_files = Split('''
|
|||||||
GuiDelimiterDialog.cpp
|
GuiDelimiterDialog.cpp
|
||||||
GuiDialogView.cpp
|
GuiDialogView.cpp
|
||||||
GuiDocument.cpp
|
GuiDocument.cpp
|
||||||
|
GuiEmbeddedFiles.cpp
|
||||||
GuiErrorList.cpp
|
GuiErrorList.cpp
|
||||||
GuiERT.cpp
|
GuiERT.cpp
|
||||||
GuiExternal.cpp
|
GuiExternal.cpp
|
||||||
@ -1003,7 +1007,6 @@ src_frontends_qt4_files = Split('''
|
|||||||
GuiWrap.cpp
|
GuiWrap.cpp
|
||||||
IconPalette.cpp
|
IconPalette.cpp
|
||||||
InsertTableWidget.cpp
|
InsertTableWidget.cpp
|
||||||
KeySymbol.cpp
|
|
||||||
LengthCombo.cpp
|
LengthCombo.cpp
|
||||||
LyXFileDialog.cpp
|
LyXFileDialog.cpp
|
||||||
PanelStack.cpp
|
PanelStack.cpp
|
||||||
@ -1043,6 +1046,7 @@ src_frontends_qt4_ui_files = Split('''
|
|||||||
CitationUi.ui
|
CitationUi.ui
|
||||||
DelimiterUi.ui
|
DelimiterUi.ui
|
||||||
DocumentUi.ui
|
DocumentUi.ui
|
||||||
|
EmbeddedFilesUi.ui
|
||||||
ERTUi.ui
|
ERTUi.ui
|
||||||
ErrorListUi.ui
|
ErrorListUi.ui
|
||||||
ExternalUi.ui
|
ExternalUi.ui
|
||||||
|
@ -420,6 +420,7 @@ Menuset
|
|||||||
Item "Outline|O" "dialog-toggle toc"
|
Item "Outline|O" "dialog-toggle toc"
|
||||||
Item "Start Appendix Here|A" "appendix"
|
Item "Start Appendix Here|A" "appendix"
|
||||||
Separator
|
Separator
|
||||||
|
Item "Embedded Files|E" "dialog-show embedding"
|
||||||
Item "Compressed|m" "buffer-toggle-compression"
|
Item "Compressed|m" "buffer-toggle-compression"
|
||||||
Item "Settings...|S" "dialog-show document"
|
Item "Settings...|S" "dialog-show document"
|
||||||
End
|
End
|
||||||
|
@ -353,9 +353,7 @@ BufferParams::BufferParams()
|
|||||||
listings_params = string();
|
listings_params = string();
|
||||||
pagestyle = "default";
|
pagestyle = "default";
|
||||||
compressed = false;
|
compressed = false;
|
||||||
// temporarily enable embedding for testing. Will set to false
|
embedded = false;
|
||||||
// when embedding GUI is added
|
|
||||||
embedded = true;
|
|
||||||
for (int iter = 0; iter < 4; ++iter) {
|
for (int iter = 0; iter < 4; ++iter) {
|
||||||
user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter];
|
user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter];
|
||||||
temp_bullet(iter) = ITEMIZE_DEFAULTS[iter];
|
temp_bullet(iter) = ITEMIZE_DEFAULTS[iter];
|
||||||
|
@ -89,6 +89,11 @@ bool EmbeddedFiles::enabled() const
|
|||||||
|
|
||||||
void EmbeddedFiles::enable(bool flag)
|
void EmbeddedFiles::enable(bool flag)
|
||||||
{
|
{
|
||||||
|
// FIXME: there are much more to do here.
|
||||||
|
// If we enable embedding, it is maybe a good idea to copy embedded files
|
||||||
|
// to temppath()
|
||||||
|
// if we disable embedding, embedded files need to be copied to their
|
||||||
|
// original positions.
|
||||||
if (enabled() != flag) {
|
if (enabled() != flag) {
|
||||||
// file will be changed
|
// file will be changed
|
||||||
buffer_->markDirty();
|
buffer_->markDirty();
|
||||||
@ -216,6 +221,28 @@ bool EmbeddedFiles::write(DocFileName const & filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string EmbeddedFiles::filename(size_t idx) const
|
||||||
|
{
|
||||||
|
return (file_list_.begin() + idx)->absFilename();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EmbeddedFile::STATUS EmbeddedFiles::status(size_t idx) const
|
||||||
|
{
|
||||||
|
return (file_list_.begin() + idx)->status();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EmbeddedFiles::setStatus(size_t idx, EmbeddedFile::STATUS status)
|
||||||
|
{
|
||||||
|
if ((file_list_.begin() + idx)->status() != status) {
|
||||||
|
// file will be changed
|
||||||
|
buffer_->markDirty();
|
||||||
|
(file_list_.begin() + idx)->setStatus(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EmbeddedFiles::validInzipName(string const & name)
|
bool EmbeddedFiles::validInzipName(string const & name)
|
||||||
{
|
{
|
||||||
EmbeddedFileList::iterator it = file_list_.begin();
|
EmbeddedFileList::iterator it = file_list_.begin();
|
||||||
|
@ -211,6 +211,10 @@ public:
|
|||||||
|
|
||||||
void clear() { file_list_.clear(); }
|
void clear() { file_list_.clear(); }
|
||||||
|
|
||||||
|
/// FIXME: I am wondering if we should use index or filename (a std::map)
|
||||||
|
std::string filename(size_t idx) const;
|
||||||
|
EmbeddedFile::STATUS status(size_t idx) const;
|
||||||
|
void setStatus(size_t idx, EmbeddedFile::STATUS status);
|
||||||
///
|
///
|
||||||
EmbeddedFileList::iterator begin() { return file_list_.begin(); }
|
EmbeddedFileList::iterator begin() { return file_list_.begin(); }
|
||||||
EmbeddedFileList::iterator end() { return file_list_.end(); }
|
EmbeddedFileList::iterator end() { return file_list_.end(); }
|
||||||
|
54
src/frontends/controllers/ControlEmbeddedFiles.cpp
Normal file
54
src/frontends/controllers/ControlEmbeddedFiles.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* \file ControlEmbeddedFiles.cpp
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Bo Peng
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "ControlEmbeddedFiles.h"
|
||||||
|
|
||||||
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
#include "FuncRequest.h"
|
||||||
|
#include "gettext.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
ControlEmbeddedFiles::ControlEmbeddedFiles(Dialog & parent)
|
||||||
|
: Dialog::Controller(parent), embedded_files(NULL)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
bool ControlEmbeddedFiles::initialiseParams(string const &)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlEmbeddedFiles::updateEmbeddedFiles()
|
||||||
|
{
|
||||||
|
// copy buffer embeddedFiles to a local copy
|
||||||
|
kernel().buffer().embeddedFiles().update();
|
||||||
|
embedded_files = &kernel().buffer().embeddedFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlEmbeddedFiles::dispatchParams()
|
||||||
|
{
|
||||||
|
// lyx view will only be updated if we do something to the main window. :-)
|
||||||
|
kernel().dispatch(FuncRequest(LFUN_MESSAGE, message_));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
58
src/frontends/controllers/ControlEmbeddedFiles.h
Normal file
58
src/frontends/controllers/ControlEmbeddedFiles.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file ControlEmbeddedFiles.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Bo Peng
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONTROLEMBEDDEDFILES_H
|
||||||
|
#define CONTROLEMBEDDEDFILES_H
|
||||||
|
|
||||||
|
#include "Dialog.h"
|
||||||
|
#include "EmbeddedFiles.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class ControlEmbeddedFiles : public Dialog::Controller {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
ControlEmbeddedFiles(Dialog &);
|
||||||
|
///
|
||||||
|
virtual ~ControlEmbeddedFiles() {}
|
||||||
|
///
|
||||||
|
EmbeddedFiles const * embeddedFiles() const { return embedded_files; }
|
||||||
|
EmbeddedFiles * embeddedFiles() { return embedded_files; }
|
||||||
|
///
|
||||||
|
virtual bool initialiseParams(std::string const &);
|
||||||
|
/// obtain embedded files from buffer
|
||||||
|
void updateEmbeddedFiles();
|
||||||
|
///
|
||||||
|
virtual void clearParams() {};
|
||||||
|
///
|
||||||
|
virtual bool isBufferDependent() const { return true; }
|
||||||
|
///
|
||||||
|
bool canApply() const { return true; }
|
||||||
|
///
|
||||||
|
virtual bool canApplyToReadOnly() const { return true; }
|
||||||
|
///
|
||||||
|
void setMessage(std::string const & msg) { message_ = msg; }
|
||||||
|
///
|
||||||
|
void dispatchParams();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// directly handle buffer embedded files
|
||||||
|
EmbeddedFiles * embedded_files;
|
||||||
|
//
|
||||||
|
std::string message_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // CONTROLEMBEDDEDFILES_H
|
@ -22,6 +22,7 @@ SOURCEFILES = \
|
|||||||
ControlCommand.cpp \
|
ControlCommand.cpp \
|
||||||
ControlCommandBuffer.cpp \
|
ControlCommandBuffer.cpp \
|
||||||
ControlDocument.cpp \
|
ControlDocument.cpp \
|
||||||
|
ControlEmbeddedFiles.cpp \
|
||||||
ControlErrorList.cpp \
|
ControlErrorList.cpp \
|
||||||
ControlERT.cpp \
|
ControlERT.cpp \
|
||||||
ControlExternal.cpp \
|
ControlExternal.cpp \
|
||||||
@ -66,6 +67,7 @@ HEADERFILES = \
|
|||||||
ControlDocument.h \
|
ControlDocument.h \
|
||||||
ControlErrorList.h \
|
ControlErrorList.h \
|
||||||
ControlERT.h \
|
ControlERT.h \
|
||||||
|
ControlEmbedded.h \
|
||||||
ControlExternal.h \
|
ControlExternal.h \
|
||||||
ControlFloat.h \
|
ControlFloat.h \
|
||||||
ControlGraphics.h \
|
ControlGraphics.h \
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "ControlChanges.h"
|
#include "ControlChanges.h"
|
||||||
#include "ControlCharacter.h"
|
#include "ControlCharacter.h"
|
||||||
#include "ControlDocument.h"
|
#include "ControlDocument.h"
|
||||||
|
#include "ControlEmbeddedFiles.h"
|
||||||
#include "ControlErrorList.h"
|
#include "ControlErrorList.h"
|
||||||
#include "ControlERT.h"
|
#include "ControlERT.h"
|
||||||
#include "ControlExternal.h"
|
#include "ControlExternal.h"
|
||||||
@ -58,6 +59,7 @@
|
|||||||
#include "GuiCitationDialog.h"
|
#include "GuiCitationDialog.h"
|
||||||
#include "GuiDelimiterDialog.h"
|
#include "GuiDelimiterDialog.h"
|
||||||
#include "GuiDocument.h"
|
#include "GuiDocument.h"
|
||||||
|
#include "GuiEmbeddedFiles.h"
|
||||||
#include "GuiErrorList.h"
|
#include "GuiErrorList.h"
|
||||||
#include "GuiERT.h"
|
#include "GuiERT.h"
|
||||||
#include "GuiExternal.h"
|
#include "GuiExternal.h"
|
||||||
@ -106,7 +108,7 @@ namespace {
|
|||||||
|
|
||||||
char const * const dialognames[] = {
|
char const * const dialognames[] = {
|
||||||
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
|
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
|
||||||
"citation", "document", "errorlist", "ert", "external", "file",
|
"citation", "document", "embedding", "errorlist", "ert", "external", "file",
|
||||||
"findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
|
"findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
|
||||||
"mathdelimiter", "mathmatrix", "note", "paragraph",
|
"mathdelimiter", "mathmatrix", "note", "paragraph",
|
||||||
"prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
|
"prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
|
||||||
@ -185,6 +187,13 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
|
|||||||
dialog->setController(new ControlDocument(*dialog));
|
dialog->setController(new ControlDocument(*dialog));
|
||||||
dialog->setView(new GuiDocument(*dialog));
|
dialog->setView(new GuiDocument(*dialog));
|
||||||
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
|
||||||
|
} else if (name == "embedding") {
|
||||||
|
GuiViewBase & gui_view = static_cast<GuiViewBase &>(lyxview_);
|
||||||
|
GuiEmbeddedFiles * qef = new GuiEmbeddedFiles(*dialog);
|
||||||
|
dialog->setController(qef);
|
||||||
|
dialog->setView(new DockView<GuiEmbeddedFiles, GuiEmbeddedFilesDialog>(
|
||||||
|
*dialog, qef, &gui_view, _("Embedded Files"), Qt::RightDockWidgetArea));
|
||||||
|
dialog->bc().bp(new OkCancelPolicy);
|
||||||
} else if (name == "errorlist") {
|
} else if (name == "errorlist") {
|
||||||
dialog->setController(new ControlErrorList(*dialog));
|
dialog->setController(new ControlErrorList(*dialog));
|
||||||
dialog->setView(new GuiErrorList(*dialog));
|
dialog->setView(new GuiErrorList(*dialog));
|
||||||
|
214
src/frontends/qt4/GuiEmbeddedFiles.cpp
Normal file
214
src/frontends/qt4/GuiEmbeddedFiles.cpp
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
/**
|
||||||
|
* \file GuiEmbeddedFiles.cpp
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Bo Peng
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "GuiEmbeddedFiles.h"
|
||||||
|
#include "Qt2BC.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// GuiEmbeddedFilesDialog
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
#define INVALID_COLOR "gray"
|
||||||
|
#define AUTO_COLOR "green"
|
||||||
|
#define EMBEDDED_COLOR "black"
|
||||||
|
#define EXTERNAL_COLOR "blue"
|
||||||
|
|
||||||
|
GuiEmbeddedFilesDialog::GuiEmbeddedFilesDialog(GuiEmbeddedFiles * form)
|
||||||
|
: form_(form)
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
|
||||||
|
form_->updateEmbeddedFiles();
|
||||||
|
|
||||||
|
EmbeddedFiles const * files = form_->embeddedFiles();
|
||||||
|
enableCB->setChecked(files->enabled());
|
||||||
|
EmbeddedFiles::EmbeddedFileList::const_iterator it = files->begin();
|
||||||
|
EmbeddedFiles::EmbeddedFileList::const_iterator it_end = files->end();
|
||||||
|
for (; it != it_end; ++it) {
|
||||||
|
QListWidgetItem * item = new QListWidgetItem(toqstr(it->inzipName()));
|
||||||
|
if (!it->valid())
|
||||||
|
item->setTextColor(INVALID_COLOR);
|
||||||
|
else if(it->status() == EmbeddedFile::AUTO)
|
||||||
|
item->setTextColor(AUTO_COLOR);
|
||||||
|
else if(it->status() == EmbeddedFile::EMBEDDED)
|
||||||
|
item->setTextColor(EMBEDDED_COLOR);
|
||||||
|
else
|
||||||
|
item->setTextColor(EXTERNAL_COLOR);
|
||||||
|
filesLW->addItem(item);
|
||||||
|
}
|
||||||
|
filesLW->setCurrentRow(0);
|
||||||
|
//
|
||||||
|
actionCB->addItem("No action");
|
||||||
|
actionCB->addItem("Add file");
|
||||||
|
actionCB->addItem("Extract file");
|
||||||
|
actionCB->addItem("Extract all");
|
||||||
|
actionCB->addItem("Embed all");
|
||||||
|
actionCB->addItem("Embed layout file");
|
||||||
|
actionCB->addItem("View file");
|
||||||
|
actionCB->addItem("Edit file");
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_filesLW_itemSelectionChanged()
|
||||||
|
{
|
||||||
|
EmbeddedFiles * files = form_->embeddedFiles();
|
||||||
|
|
||||||
|
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||||
|
fullpathLE->setEnabled(selection.size() == 1);
|
||||||
|
|
||||||
|
EmbeddedFile::STATUS mode = EmbeddedFile::NONE;
|
||||||
|
// try to find a common mode, otherwise return NONE.
|
||||||
|
for (QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||||
|
it != selection.end(); ++it) {
|
||||||
|
if (selection.size() == 1)
|
||||||
|
fullpathLE->setText(toqstr(files->filename(filesLW->row(*it))));
|
||||||
|
if (mode == EmbeddedFile::NONE) {
|
||||||
|
mode = files->status(filesLW->row(*it));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (mode != files->status(filesLW->row(*it))) {
|
||||||
|
mode = EmbeddedFile::NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
autoRB->setChecked(mode == EmbeddedFile::AUTO);
|
||||||
|
embeddedRB->setChecked(mode == EmbeddedFile::EMBEDDED);
|
||||||
|
externalRB->setChecked(mode == EmbeddedFile::EXTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_filesLW_itemDoubleClicked()
|
||||||
|
{
|
||||||
|
// FIXME: view or edit file
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::update()
|
||||||
|
{
|
||||||
|
EmbeddedFiles const * files = form_->embeddedFiles();
|
||||||
|
|
||||||
|
bool enabled = files->enabled();
|
||||||
|
enableCB->setChecked(enabled);
|
||||||
|
statusGB->setEnabled(enabled);
|
||||||
|
filesLW->setEnabled(enabled);
|
||||||
|
fullpathLE->setEnabled(enabled);
|
||||||
|
actionCB->setEnabled(enabled);
|
||||||
|
actionPB->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_actionPB_clicked()
|
||||||
|
{
|
||||||
|
// FIXME.
|
||||||
|
|
||||||
|
// ACTION
|
||||||
|
string action = fromqstr(actionCB->currentText());
|
||||||
|
if (action == "Add file") {
|
||||||
|
} else if (action == "Extract file") {
|
||||||
|
} else if (action == "Extract all") {
|
||||||
|
} else if (action == "Embed all") {
|
||||||
|
} else if (action == "Embed layout file") {
|
||||||
|
} else if (action == "View file") {
|
||||||
|
} else if (action == "Edit file") {
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_actionCB_stateChanged(int idx)
|
||||||
|
{
|
||||||
|
// valid action, enable action button
|
||||||
|
actionPB->setEnabled(idx != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_enableCB_toggled(bool enable)
|
||||||
|
{
|
||||||
|
// FIXME:
|
||||||
|
//
|
||||||
|
// When a embedded file is turned to disabled, it should save its
|
||||||
|
// embedded files. Otherwise, embedded files will be lost!!!
|
||||||
|
//
|
||||||
|
form_->embeddedFiles()->enable(enable);
|
||||||
|
update();
|
||||||
|
// immediately post the change to buffer (and bufferView)
|
||||||
|
if (enable)
|
||||||
|
form_->setMessage("Enable file embedding");
|
||||||
|
else
|
||||||
|
form_->setMessage("Disable file embedding");
|
||||||
|
// update bufferView
|
||||||
|
form_->dispatchParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::set_embedding_status(EmbeddedFile::STATUS status)
|
||||||
|
{
|
||||||
|
EmbeddedFiles * files = form_->embeddedFiles();
|
||||||
|
QList<QListWidgetItem *> selection = filesLW->selectedItems();
|
||||||
|
for (QList<QListWidgetItem*>::iterator it = selection.begin();
|
||||||
|
it != selection.end(); ++it) {
|
||||||
|
files->setStatus(filesLW->row(*it), status);
|
||||||
|
if(status == EmbeddedFile::AUTO)
|
||||||
|
(*it)->setTextColor(AUTO_COLOR);
|
||||||
|
else if(status == EmbeddedFile::EMBEDDED)
|
||||||
|
(*it)->setTextColor(EMBEDDED_COLOR);
|
||||||
|
else
|
||||||
|
(*it)->setTextColor(EXTERNAL_COLOR);
|
||||||
|
}
|
||||||
|
if (status == EmbeddedFile::AUTO)
|
||||||
|
form_->setMessage("Switch to auto embedding");
|
||||||
|
else if (status == EmbeddedFile::EMBEDDED)
|
||||||
|
form_->setMessage("Switch to always embedding");
|
||||||
|
else
|
||||||
|
form_->setMessage("Switch to never embedding");
|
||||||
|
autoRB->setChecked(status == EmbeddedFile::AUTO);
|
||||||
|
embeddedRB->setChecked(status == EmbeddedFile::EMBEDDED);
|
||||||
|
externalRB->setChecked(status == EmbeddedFile::EXTERNAL);
|
||||||
|
// update bufferView
|
||||||
|
form_->dispatchParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_autoRB_clicked()
|
||||||
|
{
|
||||||
|
set_embedding_status(EmbeddedFile::AUTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_embeddedRB_clicked()
|
||||||
|
{
|
||||||
|
set_embedding_status(EmbeddedFile::EMBEDDED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiEmbeddedFilesDialog::on_externalRB_clicked()
|
||||||
|
{
|
||||||
|
set_embedding_status(EmbeddedFile::EXTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#include "GuiEmbeddedFiles_moc.cpp"
|
67
src/frontends/qt4/GuiEmbeddedFiles.h
Normal file
67
src/frontends/qt4/GuiEmbeddedFiles.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file GuiEmbeddedFiles.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Bo Peng
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GUIEMBEDDEDFILES_H
|
||||||
|
#define GUIEMBEDDEDFILES_H
|
||||||
|
|
||||||
|
#include "EmbeddedFiles.h"
|
||||||
|
#include "ControlEmbeddedFiles.h"
|
||||||
|
#include "ui_EmbeddedFilesUi.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class GuiEmbeddedFiles;
|
||||||
|
|
||||||
|
class GuiEmbeddedFilesDialog : public QWidget, public Ui::GuiEmbeddedFilesUi {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
GuiEmbeddedFilesDialog(GuiEmbeddedFiles * form);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
///
|
||||||
|
void on_filesLW_itemSelectionChanged();
|
||||||
|
///
|
||||||
|
void on_filesLW_itemDoubleClicked();
|
||||||
|
///
|
||||||
|
void update();
|
||||||
|
///
|
||||||
|
void on_actionPB_clicked();
|
||||||
|
///
|
||||||
|
void on_actionCB_stateChanged(int);
|
||||||
|
///
|
||||||
|
void on_enableCB_toggled(bool enable);
|
||||||
|
///
|
||||||
|
void on_autoRB_clicked();
|
||||||
|
void on_embeddedRB_clicked();
|
||||||
|
void on_externalRB_clicked();
|
||||||
|
private:
|
||||||
|
void set_embedding_status(EmbeddedFile::STATUS);
|
||||||
|
///
|
||||||
|
GuiEmbeddedFiles * form_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class GuiEmbeddedFiles : public QObject, public ControlEmbeddedFiles
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
/// Constructor
|
||||||
|
GuiEmbeddedFiles(Dialog & dialog)
|
||||||
|
: ControlEmbeddedFiles(dialog) {}
|
||||||
|
///
|
||||||
|
virtual ~GuiEmbeddedFiles() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // QEMBEDDEDFILES_H
|
@ -61,6 +61,7 @@ SOURCEFILES = \
|
|||||||
GuiDelimiterDialog.cpp \
|
GuiDelimiterDialog.cpp \
|
||||||
GuiDialogView.cpp \
|
GuiDialogView.cpp \
|
||||||
GuiDocument.cpp \
|
GuiDocument.cpp \
|
||||||
|
GuiEmbeddedFiles.cpp \
|
||||||
GuiErrorList.cpp \
|
GuiErrorList.cpp \
|
||||||
GuiERT.cpp \
|
GuiERT.cpp \
|
||||||
GuiExternal.cpp \
|
GuiExternal.cpp \
|
||||||
@ -158,6 +159,7 @@ MOCHEADER = \
|
|||||||
GuiDelimiterDialog.h \
|
GuiDelimiterDialog.h \
|
||||||
GuiDialogView.h \
|
GuiDialogView.h \
|
||||||
GuiDocument.h \
|
GuiDocument.h \
|
||||||
|
GuiEmbeddedFiles.h \
|
||||||
GuiErrorList.h \
|
GuiErrorList.h \
|
||||||
GuiERT.h \
|
GuiERT.h \
|
||||||
GuiExternal.h \
|
GuiExternal.h \
|
||||||
@ -225,6 +227,7 @@ UIFILES = \
|
|||||||
CitationUi.ui \
|
CitationUi.ui \
|
||||||
DelimiterUi.ui \
|
DelimiterUi.ui \
|
||||||
DocumentUi.ui \
|
DocumentUi.ui \
|
||||||
|
EmbeddedFilesUi.ui \
|
||||||
ErrorListUi.ui \
|
ErrorListUi.ui \
|
||||||
ERTUi.ui \
|
ERTUi.ui \
|
||||||
ExternalUi.ui \
|
ExternalUi.ui \
|
||||||
|
140
src/frontends/qt4/ui/EmbeddedFilesUi.ui
Normal file
140
src/frontends/qt4/ui/EmbeddedFilesUi.ui
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<ui version="4.0" >
|
||||||
|
<class>GuiEmbeddedFilesUi</class>
|
||||||
|
<widget class="QWidget" name="GuiEmbeddedFilesUi" >
|
||||||
|
<property name="windowModality" >
|
||||||
|
<enum>Qt::NonModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>100</width>
|
||||||
|
<height>390</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="enableCB" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Enable embedding</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="filesLW" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>List of embedded files</string>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode" >
|
||||||
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="currentRow" >
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="pathLBL" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>External FIle Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="fullpathLE" />
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="statusGB" >
|
||||||
|
<property name="title" >
|
||||||
|
<string>Status</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="autoRB" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Automatic inclusion</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Automatic</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoExclusive" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="embeddedRB" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Embedded</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoExclusive" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="externalRB" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>External</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoExclusive" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" >
|
||||||
|
<property name="margin" >
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing" >
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="actionCB" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Actions to perform</string>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex" >
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="actionPB" >
|
||||||
|
<property name="toolTip" >
|
||||||
|
<string>Extract this file to disk</string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Action!</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<includes>
|
||||||
|
<include location="local" >qt_helpers.h</include>
|
||||||
|
</includes>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue
Block a user