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
This commit is contained in:
Bo Peng 2007-10-16 14:41:46 +00:00
parent 9a097259be
commit b5538c32aa
6 changed files with 133 additions and 39 deletions

View File

@ -974,6 +974,7 @@ src_frontends_qt4_ui_files = Split('''
PrefPlaintextUi.ui
PrefPrinterUi.ui
PrefScreenFontsUi.ui
PrefShortcutsUi.ui
PrefSpellcheckerUi.ui
PrefUi.ui
PrefsUi.ui

View File

@ -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);

View File

@ -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

View File

@ -276,6 +276,7 @@ UIFILES = \
PrefPlaintextUi.ui \
PrefPrinterUi.ui \
PrefScreenFontsUi.ui \
PrefShortcutsUi.ui \
PrefSpellcheckerUi.ui \
PrefsUi.ui \
PrefUi.ui \

View File

@ -0,0 +1,74 @@
<ui version="4.0" >
<class>PrefShortcuts</class>
<widget class="QWidget" name="PrefShortcuts" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>418</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="2" >
<widget class="QPushButton" name="bindFilePB" >
<property name="text" >
<string>B&amp;rowse...</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="bindFileLA" >
<property name="text" >
<string>&amp;Bind file:</string>
</property>
<property name="buddy" >
<cstring>bindFileED</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="bindFileED" />
</item>
<item row="5" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>bindFileED</tabstop>
<tabstop>bindFilePB</tabstop>
</tabstops>
<includes>
<include location="local" >qt_helpers.h</include>
</includes>
<resources/>
<connections/>
</ui>

View File

@ -163,13 +163,6 @@
</layout>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="bindFilePB" >
<property name="text" >
<string>B&amp;rowse...</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="uiFileLA" >
<property name="text" >
@ -180,16 +173,6 @@
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="bindFileLA" >
<property name="text" >
<string>&amp;Bind file:</string>
</property>
<property name="buddy" >
<cstring>bindFileED</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="uiFileED" />
</item>
@ -200,9 +183,6 @@
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="bindFileED" />
</item>
<item row="2" column="0" colspan="3" >
<widget class="QGroupBox" name="GeometryGB" >
<property name="sizePolicy" >
@ -378,8 +358,6 @@
<tabstops>
<tabstop>uiFileED</tabstop>
<tabstop>uiFilePB</tabstop>
<tabstop>bindFileED</tabstop>
<tabstop>bindFilePB</tabstop>
<tabstop>loadWindowSizeCB</tabstop>
<tabstop>windowWidthSB</tabstop>
<tabstop>windowHeightSB</tabstop>