mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Preliminar InsetInfo dialog. This was done as an exercise to show Bo (an others) how easy it is to create a new dialog. This dialog needs to be filled in, right now, there is just an OK button.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25144 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cf466ab567
commit
f276338227
@ -718,6 +718,7 @@ src_frontends_qt4_header_files = Split('''
|
|||||||
GuiIdListModel.h
|
GuiIdListModel.h
|
||||||
GuiImage.h
|
GuiImage.h
|
||||||
GuiInclude.h
|
GuiInclude.h
|
||||||
|
GuiInfo.h
|
||||||
GuiKeySymbol.h
|
GuiKeySymbol.h
|
||||||
GuiLabel.h
|
GuiLabel.h
|
||||||
GuiListings.h
|
GuiListings.h
|
||||||
@ -807,6 +808,7 @@ src_frontends_qt4_files = Split('''
|
|||||||
GuiIdListModel.cpp
|
GuiIdListModel.cpp
|
||||||
GuiImage.cpp
|
GuiImage.cpp
|
||||||
GuiInclude.cpp
|
GuiInclude.cpp
|
||||||
|
GuiInfo.cpp
|
||||||
GuiKeySymbol.cpp
|
GuiKeySymbol.cpp
|
||||||
GuiLabel.cpp
|
GuiLabel.cpp
|
||||||
GuiListings.cpp
|
GuiListings.cpp
|
||||||
@ -887,6 +889,7 @@ src_frontends_qt4_ui_files = Split('''
|
|||||||
HSpaceUi.ui
|
HSpaceUi.ui
|
||||||
HyperlinkUi.ui
|
HyperlinkUi.ui
|
||||||
IncludeUi.ui
|
IncludeUi.ui
|
||||||
|
InfoUi.ui
|
||||||
LabelUi.ui
|
LabelUi.ui
|
||||||
LaTeXUi.ui
|
LaTeXUi.ui
|
||||||
LanguageUi.ui
|
LanguageUi.ui
|
||||||
|
@ -347,4 +347,13 @@ Menuset
|
|||||||
Item "Settings...|S" "inset-settings tabular"
|
Item "Settings...|S" "inset-settings tabular"
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# InsetInfo context menu
|
||||||
|
#
|
||||||
|
|
||||||
|
Menu "context-info"
|
||||||
|
Item "Settings...|S" "inset-settings"
|
||||||
|
End
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -943,6 +943,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
|||||||
bool enable = false;
|
bool enable = false;
|
||||||
InsetCode next_code = cur.nextInset()
|
InsetCode next_code = cur.nextInset()
|
||||||
? cur.nextInset()->lyxCode() : NO_CODE;
|
? cur.nextInset()->lyxCode() : NO_CODE;
|
||||||
|
//FIXME: remove these special cases:
|
||||||
switch (next_code) {
|
switch (next_code) {
|
||||||
case TABULAR_CODE:
|
case TABULAR_CODE:
|
||||||
case ERT_CODE:
|
case ERT_CODE:
|
||||||
@ -952,6 +953,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
|||||||
case BRANCH_CODE:
|
case BRANCH_CODE:
|
||||||
case BOX_CODE:
|
case BOX_CODE:
|
||||||
case LISTINGS_CODE:
|
case LISTINGS_CODE:
|
||||||
|
case INFO_CODE:
|
||||||
enable = (cmd.argument().empty() ||
|
enable = (cmd.argument().empty() ||
|
||||||
cmd.getArg(0) == insetName(next_code));
|
cmd.getArg(0) == insetName(next_code));
|
||||||
break;
|
break;
|
||||||
|
104
src/frontends/qt4/GuiInfo.cpp
Normal file
104
src/frontends/qt4/GuiInfo.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* \file GuiInfo.cpp
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "GuiInfo.h"
|
||||||
|
|
||||||
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "buffer_funcs.h"
|
||||||
|
#include "BufferParams.h"
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "Cursor.h"
|
||||||
|
#include "FuncRequest.h"
|
||||||
|
|
||||||
|
#include "insets/InsetInfo.h"
|
||||||
|
|
||||||
|
#include "support/debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// GuiInfo
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GuiInfo::GuiInfo(GuiView & lv)
|
||||||
|
: DialogView(lv, "info", qt_("Info"))
|
||||||
|
{
|
||||||
|
setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiInfo::on_closePB_clicked()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InsetInfo * GuiInfo::inset() const
|
||||||
|
{
|
||||||
|
return static_cast<InsetInfo *>(bufferview()->cursor().
|
||||||
|
innerInsetOfType(INFO_CODE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiInfo::applyView()
|
||||||
|
{
|
||||||
|
InsetInfo * ii = inset();
|
||||||
|
if (!ii)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// FIXME: update the inset contents
|
||||||
|
|
||||||
|
updateLabels(bufferview()->buffer());
|
||||||
|
bufferview()->updateMetrics();
|
||||||
|
bufferview()->buffer().changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiInfo::updateView()
|
||||||
|
{
|
||||||
|
InsetInfo * ii = inset();
|
||||||
|
if (!ii) {
|
||||||
|
// FIXME: A New button to create an InsetInfo at the cursor location
|
||||||
|
// would be nice.
|
||||||
|
enableView(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//FIXME: update the controls.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiInfo::enableView(bool enable)
|
||||||
|
{
|
||||||
|
//FIXME: enable controls that need enabling.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiInfo::dispatchParams()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Dialog * createGuiInfo(GuiView & lv) { return new GuiInfo(lv); }
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#include "GuiInfo_moc.cpp"
|
51
src/frontends/qt4/GuiInfo.h
Normal file
51
src/frontends/qt4/GuiInfo.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file GuiInfo.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GUI_INFO_H
|
||||||
|
#define GUI_INFO_H
|
||||||
|
|
||||||
|
#include "DialogView.h"
|
||||||
|
#include "ui_InfoUi.h"
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
|
||||||
|
class InsetInfo;
|
||||||
|
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
class GuiInfo : public DialogView, public Ui::InfoUi
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GuiInfo(GuiView & lv);
|
||||||
|
|
||||||
|
/// Dialog inherited methods
|
||||||
|
//@{
|
||||||
|
void applyView();
|
||||||
|
void updateView();
|
||||||
|
void dispatchParams();
|
||||||
|
void enableView(bool enable);
|
||||||
|
bool isBufferDependent() const { return true; }
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void on_closePB_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
InsetInfo * inset() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#endif // GUI_INFO_H
|
@ -2079,7 +2079,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", "errorlist", "ert", "external", "file",
|
||||||
"findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log",
|
"findreplace", "float", "graphics", "include", "index", "info", "nomenclature", "label", "log",
|
||||||
"mathdelimiter", "mathmatrix", "note", "paragraph", "prefs", "print",
|
"mathdelimiter", "mathmatrix", "note", "paragraph", "prefs", "print",
|
||||||
"ref", "sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate",
|
"ref", "sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate",
|
||||||
|
|
||||||
@ -2252,6 +2252,7 @@ Dialog * createGuiFloat(GuiView & lv);
|
|||||||
Dialog * createGuiGraphics(GuiView & lv);
|
Dialog * createGuiGraphics(GuiView & lv);
|
||||||
Dialog * createGuiHSpace(GuiView & lv);
|
Dialog * createGuiHSpace(GuiView & lv);
|
||||||
Dialog * createGuiInclude(GuiView & lv);
|
Dialog * createGuiInclude(GuiView & lv);
|
||||||
|
Dialog * createGuiInfo(GuiView & lv);
|
||||||
Dialog * createGuiLabel(GuiView & lv);
|
Dialog * createGuiLabel(GuiView & lv);
|
||||||
Dialog * createGuiListings(GuiView & lv);
|
Dialog * createGuiListings(GuiView & lv);
|
||||||
Dialog * createGuiLog(GuiView & lv);
|
Dialog * createGuiLog(GuiView & lv);
|
||||||
@ -2316,6 +2317,8 @@ Dialog * GuiView::build(string const & name)
|
|||||||
return createGuiGraphics(*this);
|
return createGuiGraphics(*this);
|
||||||
if (name == "include")
|
if (name == "include")
|
||||||
return createGuiInclude(*this);
|
return createGuiInclude(*this);
|
||||||
|
if (name == "info")
|
||||||
|
return createGuiInfo(*this);
|
||||||
if (name == "nomenclature")
|
if (name == "nomenclature")
|
||||||
return createGuiNomenclature(*this);
|
return createGuiNomenclature(*this);
|
||||||
if (name == "label")
|
if (name == "label")
|
||||||
|
@ -89,6 +89,7 @@ SOURCEFILES = \
|
|||||||
GuiIdListModel.cpp \
|
GuiIdListModel.cpp \
|
||||||
GuiImage.cpp \
|
GuiImage.cpp \
|
||||||
GuiInclude.cpp \
|
GuiInclude.cpp \
|
||||||
|
GuiInfo.cpp \
|
||||||
GuiKeySymbol.cpp \
|
GuiKeySymbol.cpp \
|
||||||
GuiLabel.cpp \
|
GuiLabel.cpp \
|
||||||
GuiListings.cpp \
|
GuiListings.cpp \
|
||||||
@ -182,6 +183,7 @@ MOCHEADER = \
|
|||||||
GuiHSpace.h \
|
GuiHSpace.h \
|
||||||
GuiHyperlink.h \
|
GuiHyperlink.h \
|
||||||
GuiInclude.h \
|
GuiInclude.h \
|
||||||
|
GuiInfo.h \
|
||||||
GuiLabel.h \
|
GuiLabel.h \
|
||||||
GuiListings.h \
|
GuiListings.h \
|
||||||
GuiLog.h \
|
GuiLog.h \
|
||||||
@ -247,6 +249,7 @@ UIFILES = \
|
|||||||
HSpaceUi.ui \
|
HSpaceUi.ui \
|
||||||
HyperlinkUi.ui \
|
HyperlinkUi.ui \
|
||||||
IncludeUi.ui \
|
IncludeUi.ui \
|
||||||
|
InfoUi.ui \
|
||||||
LabelUi.ui \
|
LabelUi.ui \
|
||||||
LanguageUi.ui \
|
LanguageUi.ui \
|
||||||
LaTeXUi.ui \
|
LaTeXUi.ui \
|
||||||
|
52
src/frontends/qt4/ui/InfoUi.ui
Normal file
52
src/frontends/qt4/ui/InfoUi.ui
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<ui version="4.0" >
|
||||||
|
<class>InfoUi</class>
|
||||||
|
<widget class="QDialog" name="InfoUi" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>161</width>
|
||||||
|
<height>121</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout" >
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<spacer name="spacer" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType" >
|
||||||
|
<enum>QSizePolicy::Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0" >
|
||||||
|
<size>
|
||||||
|
<width>84</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QPushButton" name="closePB" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Close</string>
|
||||||
|
</property>
|
||||||
|
<property name="default" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<includes>
|
||||||
|
<include location="local" >qt_i18n.h</include>
|
||||||
|
</includes>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -16,6 +16,7 @@
|
|||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
#include "FuncStatus.h"
|
||||||
#include "InsetGraphics.h"
|
#include "InsetGraphics.h"
|
||||||
#include "InsetSpecialChar.h"
|
#include "InsetSpecialChar.h"
|
||||||
#include "KeyMap.h"
|
#include "KeyMap.h"
|
||||||
@ -139,6 +140,32 @@ void InsetInfo::write(ostream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InsetInfo::showInsetDialog(BufferView * bv) const
|
||||||
|
{
|
||||||
|
bv->showDialog("info", "", const_cast<InsetInfo *>(this));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InsetInfo::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||||
|
FuncStatus & flag) const
|
||||||
|
{
|
||||||
|
switch (cmd.action) {
|
||||||
|
|
||||||
|
case LFUN_INSET_MODIFY:
|
||||||
|
flag.setEnabled(true);
|
||||||
|
break;
|
||||||
|
//FIXME: do something.
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
|
void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
// FIXME: we should allow selection, copy etc...
|
// FIXME: we should allow selection, copy etc...
|
||||||
@ -289,4 +316,10 @@ bool InsetInfo::setMouseHover(bool mouse_hover)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring InsetInfo::contextMenu(BufferView const &, int, int) const
|
||||||
|
{
|
||||||
|
return from_ascii("context-info");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -105,6 +105,10 @@ public:
|
|||||||
///
|
///
|
||||||
void write(std::ostream & os) const;
|
void write(std::ostream & os) const;
|
||||||
///
|
///
|
||||||
|
bool showInsetDialog(BufferView * bv) const;
|
||||||
|
///
|
||||||
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||||
|
///
|
||||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
///
|
///
|
||||||
InsetCode lyxCode() const { return INFO_CODE; }
|
InsetCode lyxCode() const { return INFO_CODE; }
|
||||||
@ -116,6 +120,8 @@ public:
|
|||||||
bool setMouseHover(bool mouse_hover);
|
bool setMouseHover(bool mouse_hover);
|
||||||
///
|
///
|
||||||
docstring toolTip(BufferView const & bv, int x, int y) const;
|
docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||||
|
///
|
||||||
|
docstring contextMenu(BufferView const &, int, int) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The translator between the information type enum and corresponding string.
|
/// The translator between the information type enum and corresponding string.
|
||||||
|
Loading…
Reference in New Issue
Block a user