From b5538c32aadd149d7076d23b57a7745befc184ae Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Tue, 16 Oct 2007 14:41:46 +0000 Subject: [PATCH] Separate PrefShortcuts from PrefUi, in preparation for a shortcuts configuration panel git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20989 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 1 + src/frontends/qt4/GuiPrefs.cpp | 57 +++++++++++++------ src/frontends/qt4/GuiPrefs.h | 17 +++++- src/frontends/qt4/Makefile.am | 1 + src/frontends/qt4/ui/PrefShortcutsUi.ui | 74 +++++++++++++++++++++++++ src/frontends/qt4/ui/PrefUi.ui | 22 -------- 6 files changed, 133 insertions(+), 39 deletions(-) create mode 100644 src/frontends/qt4/ui/PrefShortcutsUi.ui diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index fb519458e8..19c06f6e36 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -974,6 +974,7 @@ src_frontends_qt4_ui_files = Split(''' PrefPlaintextUi.ui PrefPrinterUi.ui PrefScreenFontsUi.ui + PrefShortcutsUi.ui PrefSpellcheckerUi.ui PrefUi.ui PrefsUi.ui diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index f17e9acd41..a6d42c34c5 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1583,12 +1583,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) TextLabel1, SLOT(setEnabled(bool))); connect(uiFilePB, SIGNAL(clicked()), this, SLOT(select_ui())); - connect(bindFilePB, SIGNAL(clicked()), - this, SLOT(select_bind())); connect(uiFileED, SIGNAL(textChanged(const QString &)), this, SIGNAL(changed())); - connect(bindFileED, SIGNAL(textChanged(const QString &)), - this, SIGNAL(changed())); connect(restoreCursorCB, SIGNAL(clicked()), this, SIGNAL(changed())); connect(loadSessionCB, SIGNAL(clicked()), @@ -1616,7 +1612,6 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) void PrefUserInterface::apply(LyXRC & rc) const { rc.ui_file = internal_path(fromqstr(uiFileED->text())); - rc.bind_file = internal_path(fromqstr(bindFileED->text())); rc.use_lastfilepos = restoreCursorCB->isChecked(); rc.load_session = loadSessionCB->isChecked(); if (loadWindowSizeCB->isChecked()) { @@ -1637,7 +1632,6 @@ void PrefUserInterface::apply(LyXRC & rc) const void PrefUserInterface::update(LyXRC const & rc) { uiFileED->setText(toqstr(external_path(rc.ui_file))); - bindFileED->setText(toqstr(external_path(rc.bind_file))); restoreCursorCB->setChecked(rc.use_lastfilepos); loadSessionCB->setChecked(rc.load_session); bool loadWindowSize = rc.geometry_width == 0 && rc.geometry_height == 0; @@ -1668,16 +1662,6 @@ void PrefUserInterface::select_ui() } -void PrefUserInterface::select_bind() -{ - docstring const name = - from_utf8(internal_path(fromqstr(bindFileED->text()))); - docstring file = form_->browsebind(name); - if (!file.empty()) - bindFileED->setText(toqstr(file)); -} - - void PrefUserInterface::on_loadWindowSizeCB_toggled(bool loadwindowsize) { windowWidthLA->setDisabled(loadwindowsize); @@ -1687,6 +1671,46 @@ void PrefUserInterface::on_loadWindowSizeCB_toggled(bool loadwindowsize) } +///////////////////////////////////////////////////////////////////// +// +// PrefShortcuts +// +///////////////////////////////////////////////////////////////////// + +PrefShortcuts::PrefShortcuts(GuiPreferences * form, QWidget * parent) + : PrefModule(_("Shortcuts"), form, parent) +{ + setupUi(this); + + connect(bindFilePB, SIGNAL(clicked()), + this, SLOT(select_bind())); + connect(bindFileED, SIGNAL(textChanged(const QString &)), + this, SIGNAL(changed())); +} + + +void PrefShortcuts::apply(LyXRC & rc) const +{ + rc.bind_file = internal_path(fromqstr(bindFileED->text())); +} + + +void PrefShortcuts::update(LyXRC const & rc) +{ + bindFileED->setText(toqstr(external_path(rc.bind_file))); +} + + +void PrefShortcuts::select_bind() +{ + docstring const name = + from_utf8(internal_path(fromqstr(bindFileED->text()))); + docstring file = form_->browsebind(name); + if (!file.empty()) + bindFileED->setText(toqstr(file)); +} + + PrefIdentity::PrefIdentity(QWidget * parent) : PrefModule(_("Identity"), 0, parent) { @@ -1734,6 +1758,7 @@ GuiPreferences::GuiPreferences(LyXView & lv) connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore())); add(new PrefUserInterface(this)); + add(new PrefShortcuts(this)); add(new PrefScreenFonts(this)); add(new PrefColors(this)); add(new PrefDisplay); diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index 70ad48eee0..d4ca92472d 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -30,6 +30,7 @@ #include "ui_PrefColorsUi.h" #include "ui_PrefDisplayUi.h" #include "ui_PrefPathsUi.h" +#include "ui_PrefShortcutsUi.h" #include "ui_PrefSpellcheckerUi.h" #include "ui_PrefConvertersUi.h" #include "ui_PrefFileformatsUi.h" @@ -338,12 +339,26 @@ public: public Q_SLOTS: void select_ui(); - void select_bind(); void on_loadWindowSizeCB_toggled(bool); }; +class PrefShortcuts : public PrefModule, public Ui::PrefShortcuts +{ + Q_OBJECT +public: + PrefShortcuts(GuiPreferences * form, QWidget * parent = 0); + + void apply(LyXRC & rc) const; + void update(LyXRC const & rc); + +public Q_SLOTS: + void select_bind(); + +}; + + class PrefIdentity : public PrefModule, public Ui::PrefIdentityUi { Q_OBJECT diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index 583e0c85f9..0cb90ec9d0 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -276,6 +276,7 @@ UIFILES = \ PrefPlaintextUi.ui \ PrefPrinterUi.ui \ PrefScreenFontsUi.ui \ + PrefShortcutsUi.ui \ PrefSpellcheckerUi.ui \ PrefsUi.ui \ PrefUi.ui \ diff --git a/src/frontends/qt4/ui/PrefShortcutsUi.ui b/src/frontends/qt4/ui/PrefShortcutsUi.ui new file mode 100644 index 0000000000..57810409c6 --- /dev/null +++ b/src/frontends/qt4/ui/PrefShortcutsUi.ui @@ -0,0 +1,74 @@ + + PrefShortcuts + + + + 0 + 0 + 398 + 418 + + + + + 1 + 1 + 0 + 0 + + + + + + + + 9 + + + 6 + + + + + B&rowse... + + + + + + + &Bind file: + + + bindFileED + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + bindFileED + bindFilePB + + + qt_helpers.h + + + + diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui index 6fdd3a6fb7..4edfe17e82 100644 --- a/src/frontends/qt4/ui/PrefUi.ui +++ b/src/frontends/qt4/ui/PrefUi.ui @@ -163,13 +163,6 @@ - - - - B&rowse... - - - @@ -180,16 +173,6 @@ - - - - &Bind file: - - - bindFileED - - - @@ -200,9 +183,6 @@ - - - @@ -378,8 +358,6 @@ uiFileED uiFilePB - bindFileED - bindFilePB loadWindowSizeCB windowWidthSB windowHeightSB -- 2.39.5