Proposal for a more structured UI.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32962 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-01-11 07:30:45 +00:00
parent ddebdc4514
commit 8d0378b75d
3 changed files with 178 additions and 151 deletions

View File

@ -6,6 +6,7 @@
* *
* \author Peter Kümmel * \author Peter Kümmel
* \author Pavel Sanda * \author Pavel Sanda
* \author Jürgen Spitzmüller
* *
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
@ -34,23 +35,9 @@ namespace lyx {
namespace frontend { namespace frontend {
struct LevelButton : QCheckBox
{
LevelButton(const QString& name) : QCheckBox(name) {}
Debug::Type level;
void setCheckStatusSilent(Qt::CheckState state) {
blockSignals(true);
setCheckState(state);
blockSignals(false);
}
};
ProgressViewWidget::ProgressViewWidget() ProgressViewWidget::ProgressViewWidget()
{ {
setupUi(this); setupUi(this);
} }
@ -61,7 +48,8 @@ GuiProgressView::~GuiProgressView()
GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area, GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
Qt::WindowFlags flags) : DockView(parent, "progress", "Debug/Progress window", area, flags) Qt::WindowFlags flags)
: DockView(parent, "progress", "Debug/Progress window", area, flags)
{ {
widget_ = new ProgressViewWidget(); widget_ = new ProgressViewWidget();
#if QT_VERSION < 0x040400 #if QT_VERSION < 0x040400
@ -78,26 +66,33 @@ GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
widget_->outTE->setFont(font); widget_->outTE->setFont(font);
widget_->tabWidget->widget(0)->setContentsMargins(-5, -7, 0, -7); widget_->tabWidget->widget(0)->setContentsMargins(-5, -7, 0, -7);
toggle_button = new LevelButton("Toggle ALL messages"); connect(widget_->debugNoneRB, SIGNAL(clicked()),
toggle_button->level = Debug::ANY; this, SLOT(debugSelectionChanged()));
toggle_button->setTristate(true); connect(widget_->debugSelectedRB, SIGNAL(clicked()),
toggle_button->setCheckState(Qt::PartiallyChecked); this, SLOT(debugSelectionChanged()));
widget_->settingsLayout->addWidget(toggle_button); connect(widget_->debugAnyRB, SIGNAL(clicked()),
connect(toggle_button, SIGNAL(stateChanged(int)), this, SLOT(tristateChanged(int))); this, SLOT(debugSelectionChanged()));
widget_->debugMessagesTW->setEnabled(false);
widget_->debugNoneRB->setChecked(true);
// ignore Debug::NONE and Debug::ANY // ignore Debug::NONE and Debug::ANY
int const level_count = Debug::levelCount() - 1; int const level_count = Debug::levelCount() - 1;
QTreeWidgetItem * item = 0;
widget_->debugMessagesTW->setColumnCount(2);
widget_->debugMessagesTW->headerItem()->setText(0, qt_("Debug Level"));
widget_->debugMessagesTW->headerItem()->setText(1, qt_("Display"));
for (int i = 1 ; i < level_count; i++) { for (int i = 1 ; i < level_count; i++) {
item = new QTreeWidgetItem(widget_->debugMessagesTW);
Debug::Type const level = Debug::value(i); Debug::Type const level = Debug::value(i);
LevelButton * box = new LevelButton(toqstr(Debug::description(level))); item->setText(0, toqstr(Debug::description(level)));
box->level = level; item->setData(0, Qt::UserRole, int(level));
widget_->settingsLayout->addWidget(box, (i + 3) % 10, (i + 3) / 10); item->setText(1, qt_("No"));
box->setChecked(false);
level_buttons << box;
connect(box, SIGNAL(stateChanged(int)), this, SLOT(levelChanged()));
} }
widget_->settingsLayout->activate(); widget_->debugMessagesTW->resizeColumnToContents(0);
connect(widget_->debugMessagesTW,
SIGNAL(itemActivated(QTreeWidgetItem *, int)),
this, SLOT(debugMessageActivated(QTreeWidgetItem *, int)));
GuiProgress * progress = GuiProgress * progress =
dynamic_cast<GuiProgress *>(ProgressInterface::instance()); dynamic_cast<GuiProgress *>(ProgressInterface::instance());
@ -118,36 +113,46 @@ GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
} }
void GuiProgressView::levelChanged() void GuiProgressView::debugMessageActivated(QTreeWidgetItem * item, int)
{ {
int level = Debug::NONE; if (item == 0)
checked_buttons.clear(); return;
Q_FOREACH(LevelButton* button, level_buttons) {
if (button->isChecked()) { QString const no = qt_("No");
level |= button->level; QString const yes = qt_("Yes");
checked_buttons << button;
} bool selected = (item->text(1) == yes);
} item->setText(1, selected ? no : yes);
dispatch(FuncRequest(LFUN_DEBUG_LEVEL_SET, convert<string>(level)));
levelChanged();
toggle_button->setCheckStatusSilent (Qt::PartiallyChecked);
} }
void GuiProgressView::tristateChanged(int state) void GuiProgressView::levelChanged()
{ {
if (state != Qt::PartiallyChecked) { int level = Debug::NONE;
Q_FOREACH(LevelButton* button, level_buttons) { QTreeWidgetItemIterator it(widget_->debugMessagesTW);
button->setCheckStatusSilent(toggle_button->checkState()); while (*it) {
} if ((*it)->text(1) == qt_("Yes"))
int level = (state == Qt::Checked ? Debug::ANY : Debug::NONE); level |= (*it)->data(0, Qt::UserRole).toInt();
dispatch(FuncRequest(LFUN_DEBUG_LEVEL_SET, convert<string>(level))); ++it;
} else {
Q_FOREACH(LevelButton* button, checked_buttons) {
button->setCheckStatusSilent(Qt::Checked);
}
levelChanged();
} }
dispatch(FuncRequest(LFUN_DEBUG_LEVEL_SET, convert<string>(level)));
}
void GuiProgressView::debugSelectionChanged()
{
int level = Debug::NONE;
if (widget_->debugAnyRB->isChecked())
level = Debug::ANY;
else if (widget_->debugSelectedRB->isChecked()) {
widget_->debugMessagesTW->setEnabled(true);
levelChanged();
return;
}
widget_->debugMessagesTW->setEnabled(false);
dispatch(FuncRequest(LFUN_DEBUG_LEVEL_SET, convert<string>(level)));
} }
@ -220,8 +225,6 @@ void GuiProgressView::hideEvent(QHideEvent*)
} }
Dialog * createGuiProgressView(GuiView & guiview) Dialog * createGuiProgressView(GuiView & guiview)
{ {
#ifdef Q_WS_MACX #ifdef Q_WS_MACX

View File

@ -34,8 +34,6 @@ class QShowEvent;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
struct LevelButton;
class ProgressViewWidget : public QWidget, public Ui::ProgressViewUi class ProgressViewWidget : public QWidget, public Ui::ProgressViewUi
{ {
@ -76,19 +74,15 @@ private Q_SLOTS:
void appendText(QString const & text); void appendText(QString const & text);
void appendLyXErrText(QString const & text); void appendLyXErrText(QString const & text);
void clearText(); void clearText();
void debugMessageActivated(QTreeWidgetItem *, int);
void levelChanged(); void debugSelectionChanged();
void tristateChanged(int state);
private: private:
ProgressViewWidget * widget_; ProgressViewWidget * widget_;
void levelChanged();
void showEvent(QShowEvent*); void showEvent(QShowEvent*);
void hideEvent(QHideEvent*); void hideEvent(QHideEvent*);
QList<LevelButton*> level_buttons;
QList<LevelButton*> checked_buttons;
LevelButton* toggle_button;
}; };

View File

@ -1,7 +1,7 @@
<ui version="4.0" > <ui version="4.0">
<class>ProgressViewUi</class> <class>ProgressViewUi</class>
<widget class="QWidget" name="ProgressViewUi" > <widget class="QWidget" name="ProgressViewUi">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
@ -9,149 +9,179 @@
<height>518</height> <height>518</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string/> <string/>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2" > <layout class="QGridLayout" name="gridLayout_4">
<item> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget" > <widget class="QTabWidget" name="tabWidget">
<property name="enabled" > <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy> <sizepolicy hsizetype="Expanding" vsizetype="Ignored">
<vsizetype>13</vsizetype>
<hsizetype>7</hsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="baseSize" > <property name="baseSize">
<size> <size>
<width>0</width> <width>0</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="acceptDrops" > <property name="acceptDrops">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="layoutDirection" > <property name="layoutDirection">
<enum>Qt::LeftToRight</enum> <enum>Qt::LeftToRight</enum>
</property> </property>
<property name="autoFillBackground" > <property name="autoFillBackground">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="tabPosition" > <property name="tabPosition">
<enum>QTabWidget::East</enum> <enum>QTabWidget::East</enum>
</property> </property>
<property name="tabShape" > <property name="tabShape">
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex" > <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
<property name="iconSize" > <property name="iconSize">
<size> <size>
<width>16</width> <width>16</width>
<height>16</height> <height>16</height>
</size> </size>
</property> </property>
<property name="usesScrollButtons" > <property name="usesScrollButtons">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="tab" > <widget class="QWidget" name="tab">
<attribute name="title" > <attribute name="title">
<string>Output</string> <string>Output</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_2" > <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" > <item row="0" column="0">
<widget class="QTextEdit" name="outTE" > <widget class="QTextEdit" name="outTE">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy> <sizepolicy hsizetype="Expanding" vsizetype="Ignored">
<vsizetype>13</vsizetype>
<hsizetype>7</hsizetype>
<horstretch>1</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="maximumSize" > <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
<property name="frameShape" > <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
</property> </property>
<property name="frameShadow" > <property name="frameShadow">
<enum>QFrame::Sunken</enum> <enum>QFrame::Sunken</enum>
</property> </property>
<property name="lineWidth" > <property name="lineWidth">
<number>1</number> <number>1</number>
</property> </property>
<property name="readOnly" > <property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2" > <widget class="QWidget" name="tab_2">
<attribute name="title" > <attribute name="title">
<string>Settings</string> <string>Settings</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QGridLayout" name="gridLayout_3">
<item> <item row="0" column="0">
<widget class="QScrollArea" name="scrollArea" > <widget class="QCheckBox" name="sbarCB">
<property name="widgetResizable" > <property name="toolTip">
<string>Display statusbar messages?</string>
</property>
<property name="text">
<string>&amp;Statusbar messages</string>
</property>
<property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="scrollAreaWidgetContents" > </widget>
<property name="geometry" > </item>
<rect> <item row="0" column="1" rowspan="4">
<x>0</x> <widget class="QTreeWidget" name="debugMessagesTW">
<y>0</y> <property name="toolTip">
<width>480</width> <string>Select the debug messages that should be displayed</string>
<height>474</height> </property>
</rect> <column>
<property name="text">
<string notr="true">1</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" > </column>
<item> </widget>
<layout class="QGridLayout" name="settingsLayout" > </item>
<item row="0" column="0" > <item row="1" column="0">
<widget class="QCheckBox" name="autoClearCB" > <widget class="QGroupBox" name="groupBox">
<property name="toolTip" > <property name="title">
<string>Automatic cleanup of the window before LaTeX compilation proceeds</string> <string>Debug messages</string>
</property> </property>
<property name="text" > <layout class="QGridLayout" name="gridLayout">
<string>&amp;Automatic clear</string> <item row="0" column="0">
</property> <widget class="QRadioButton" name="debugNoneRB">
<property name="checked" > <property name="toolTip">
<bool>true</bool> <string>Display no debug messages</string>
</property> </property>
</widget> <property name="text">
</item> <string>&amp;None</string>
<item row="1" column="0" > </property>
<widget class="QCheckBox" name="sbarCB" > </widget>
<property name="text" > </item>
<string>Statusbar messages</string> <item row="1" column="0">
</property> <widget class="QRadioButton" name="debugSelectedRB">
<property name="checked" > <property name="toolTip">
<bool>true</bool> <string>Display the debug messages selected to the right</string>
</property> </property>
</widget> <property name="text">
</item> <string>S&amp;elected</string>
<item row="2" column="0" > </property>
<widget class="QLabel" name="label" > </widget>
<property name="text" > </item>
<string>----- Debugging levels -----</string> <item row="2" column="0">
</property> <widget class="QRadioButton" name="debugAnyRB">
</widget> <property name="toolTip">
</item> <string>Display all debug messages</string>
</layout> </property>
</item> <property name="text">
</layout> <string>&amp;All</string>
</widget> </property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>187</width>
<height>404</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="autoClearCB">
<property name="toolTip">
<string>Automatic cleanup of the window before LaTeX compilation proceeds</string>
</property>
<property name="text">
<string>&amp;Clear automatically</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -161,7 +191,7 @@
</layout> </layout>
</widget> </widget>
<includes> <includes>
<include location="local" >qt_i18n.h</include> <include location="local">qt_i18n.h</include>
</includes> </includes>
<resources/> <resources/>
<connections/> <connections/>