]> git.lyx.org Git - features.git/commitdiff
Preliminar InsetInfo dialog. This was done as an exercise to show Bo (an others)...
authorAbdelrazak Younes <younes@lyx.org>
Thu, 5 Jun 2008 15:08:46 +0000 (15:08 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 5 Jun 2008 15:08:46 +0000 (15:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25144 a592a061-630c-0410-9148-cb99ea01b6c8

development/scons/scons_manifest.py
lib/ui/stdcontext.inc
src/BufferView.cpp
src/frontends/qt4/GuiInfo.cpp [new file with mode: 0644]
src/frontends/qt4/GuiInfo.h [new file with mode: 0644]
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/Makefile.am
src/frontends/qt4/ui/InfoUi.ui [new file with mode: 0644]
src/insets/InsetInfo.cpp
src/insets/InsetInfo.h

index 816b9b117241d50be53e2ef4b3b4f5630b14f1a5..ab30a4b0d08113403edecbca7e2b9e8f14c569db 100644 (file)
@@ -718,6 +718,7 @@ src_frontends_qt4_header_files = Split('''
     GuiIdListModel.h
     GuiImage.h
     GuiInclude.h
+    GuiInfo.h
     GuiKeySymbol.h
     GuiLabel.h
     GuiListings.h
@@ -807,6 +808,7 @@ src_frontends_qt4_files = Split('''
     GuiIdListModel.cpp 
     GuiImage.cpp
     GuiInclude.cpp
+    GuiInfo.cpp
     GuiKeySymbol.cpp
     GuiLabel.cpp
     GuiListings.cpp
@@ -887,6 +889,7 @@ src_frontends_qt4_ui_files = Split('''
     HSpaceUi.ui
     HyperlinkUi.ui
     IncludeUi.ui
+    InfoUi.ui
     LabelUi.ui
     LaTeXUi.ui
     LanguageUi.ui
index 97f0cda1f7ac6dbf87592958eee05de75670c05e..784a3a7d7d7472da51762974bdbf0c0f6902a2d8 100644 (file)
@@ -347,4 +347,13 @@ Menuset
                Item "Settings...|S" "inset-settings tabular"
        End
 
+
+#
+# InsetInfo context menu
+#
+
+       Menu "context-info"
+               Item "Settings...|S" "inset-settings"
+       End
+
 End
index 13e90d23f7a3bb4dbfc6567c4b044346329a4556..4ae5627279a8b6da6b4b837d623f0e9931cbee2b 100644 (file)
@@ -943,6 +943,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
                bool enable = false;
                InsetCode next_code = cur.nextInset()
                        ? cur.nextInset()->lyxCode() : NO_CODE;
+               //FIXME: remove these special cases:
                switch (next_code) {
                        case TABULAR_CODE:
                        case ERT_CODE:
@@ -952,6 +953,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
                        case BRANCH_CODE:
                        case BOX_CODE:
                        case LISTINGS_CODE:
+                       case INFO_CODE:
                                enable = (cmd.argument().empty() ||
                                          cmd.getArg(0) == insetName(next_code));
                                break;
diff --git a/src/frontends/qt4/GuiInfo.cpp b/src/frontends/qt4/GuiInfo.cpp
new file mode 100644 (file)
index 0000000..d8a104d
--- /dev/null
@@ -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"
diff --git a/src/frontends/qt4/GuiInfo.h b/src/frontends/qt4/GuiInfo.h
new file mode 100644 (file)
index 0000000..c23525a
--- /dev/null
@@ -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
index 90e33c36ab8ebf0d12b1605b92657eda77866e71..c71c7000ed444690a6ddda00a324fdac02caf904 100644 (file)
@@ -2079,7 +2079,7 @@ namespace {
 char const * const dialognames[] = {
 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
 "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", 
 "ref", "sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate",
 
@@ -2252,6 +2252,7 @@ Dialog * createGuiFloat(GuiView & lv);
 Dialog * createGuiGraphics(GuiView & lv);
 Dialog * createGuiHSpace(GuiView & lv);
 Dialog * createGuiInclude(GuiView & lv);
+Dialog * createGuiInfo(GuiView & lv);
 Dialog * createGuiLabel(GuiView & lv);
 Dialog * createGuiListings(GuiView & lv);
 Dialog * createGuiLog(GuiView & lv);
@@ -2316,6 +2317,8 @@ Dialog * GuiView::build(string const & name)
                return createGuiGraphics(*this);
        if (name == "include")
                return createGuiInclude(*this);
+       if (name == "info")
+               return createGuiInfo(*this);
        if (name == "nomenclature")
                return createGuiNomenclature(*this);
        if (name == "label")
index 6cba0cee25f84365ec2bd0c4e5a245d62e6bf95c..14eeea81b28ef0a533045409c5cfa3673b3d9031 100644 (file)
@@ -89,6 +89,7 @@ SOURCEFILES = \
        GuiIdListModel.cpp \
        GuiImage.cpp \
        GuiInclude.cpp \
+       GuiInfo.cpp \
        GuiKeySymbol.cpp \
        GuiLabel.cpp \
        GuiListings.cpp \
@@ -182,6 +183,7 @@ MOCHEADER = \
        GuiHSpace.h \
        GuiHyperlink.h \
        GuiInclude.h \
+       GuiInfo.h \
        GuiLabel.h \
        GuiListings.h \
        GuiLog.h \
@@ -247,6 +249,7 @@ UIFILES = \
        HSpaceUi.ui \
        HyperlinkUi.ui \
        IncludeUi.ui \
+       InfoUi.ui \
        LabelUi.ui \
        LanguageUi.ui \
        LaTeXUi.ui \
diff --git a/src/frontends/qt4/ui/InfoUi.ui b/src/frontends/qt4/ui/InfoUi.ui
new file mode 100644 (file)
index 0000000..8dc4650
--- /dev/null
@@ -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>&amp;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>
index 271539b4b6096460f98359f9c3fdfa6ad812bfd6..2d093714212ded393f20359eb57795f280ef5ee2 100644 (file)
@@ -16,6 +16,7 @@
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "FuncRequest.h"
+#include "FuncStatus.h"
 #include "InsetGraphics.h"
 #include "InsetSpecialChar.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)
 {
        // FIXME: we should allow selection, copy etc...
@@ -289,4 +316,10 @@ bool InsetInfo::setMouseHover(bool mouse_hover)
        return true;
 }
 
+
+docstring InsetInfo::contextMenu(BufferView const &, int, int) const
+{
+       return from_ascii("context-info");
+}
+
 } // namespace lyx
index 9ebe468500a7009ab1c99ed66f0d34c4a0cda77a..f1e8ae65ab538bd2b433bf9805d6369762aa7fe0 100644 (file)
@@ -105,6 +105,10 @@ public:
        ///
        void write(std::ostream & os) const;
        ///
+       bool showInsetDialog(BufferView * bv) const;
+       ///
+       bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
+       ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
        InsetCode lyxCode() const { return INFO_CODE; }
@@ -116,6 +120,8 @@ public:
        bool setMouseHover(bool mouse_hover);
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
+       ///
+       docstring contextMenu(BufferView const &, int, int) const;
 
 private:
        /// The translator between the information type enum and corresponding string.