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 Pavel Sanda
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
@ -34,23 +35,9 @@ namespace lyx {
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()
{
setupUi(this);
}
@ -61,7 +48,8 @@ GuiProgressView::~GuiProgressView()
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();
#if QT_VERSION < 0x040400
@ -78,25 +66,32 @@ GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
widget_->outTE->setFont(font);
widget_->tabWidget->widget(0)->setContentsMargins(-5, -7, 0, -7);
toggle_button = new LevelButton("Toggle ALL messages");
toggle_button->level = Debug::ANY;
toggle_button->setTristate(true);
toggle_button->setCheckState(Qt::PartiallyChecked);
widget_->settingsLayout->addWidget(toggle_button);
connect(toggle_button, SIGNAL(stateChanged(int)), this, SLOT(tristateChanged(int)));
connect(widget_->debugNoneRB, SIGNAL(clicked()),
this, SLOT(debugSelectionChanged()));
connect(widget_->debugSelectedRB, SIGNAL(clicked()),
this, SLOT(debugSelectionChanged()));
connect(widget_->debugAnyRB, SIGNAL(clicked()),
this, SLOT(debugSelectionChanged()));
widget_->debugMessagesTW->setEnabled(false);
widget_->debugNoneRB->setChecked(true);
// ignore Debug::NONE and Debug::ANY
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++) {
item = new QTreeWidgetItem(widget_->debugMessagesTW);
Debug::Type const level = Debug::value(i);
LevelButton * box = new LevelButton(toqstr(Debug::description(level)));
box->level = level;
widget_->settingsLayout->addWidget(box, (i + 3) % 10, (i + 3) / 10);
box->setChecked(false);
level_buttons << box;
connect(box, SIGNAL(stateChanged(int)), this, SLOT(levelChanged()));
item->setText(0, toqstr(Debug::description(level)));
item->setData(0, Qt::UserRole, int(level));
item->setText(1, qt_("No"));
}
widget_->settingsLayout->activate();
widget_->debugMessagesTW->resizeColumnToContents(0);
connect(widget_->debugMessagesTW,
SIGNAL(itemActivated(QTreeWidgetItem *, int)),
this, SLOT(debugMessageActivated(QTreeWidgetItem *, int)));
GuiProgress * progress =
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;
checked_buttons.clear();
Q_FOREACH(LevelButton* button, level_buttons) {
if (button->isChecked()) {
level |= button->level;
checked_buttons << button;
}
}
dispatch(FuncRequest(LFUN_DEBUG_LEVEL_SET, convert<string>(level)));
if (item == 0)
return;
toggle_button->setCheckStatusSilent (Qt::PartiallyChecked);
QString const no = qt_("No");
QString const yes = qt_("Yes");
bool selected = (item->text(1) == yes);
item->setText(1, selected ? no : yes);
levelChanged();
}
void GuiProgressView::tristateChanged(int state)
void GuiProgressView::levelChanged()
{
if (state != Qt::PartiallyChecked) {
Q_FOREACH(LevelButton* button, level_buttons) {
button->setCheckStatusSilent(toggle_button->checkState());
int level = Debug::NONE;
QTreeWidgetItemIterator it(widget_->debugMessagesTW);
while (*it) {
if ((*it)->text(1) == qt_("Yes"))
level |= (*it)->data(0, Qt::UserRole).toInt();
++it;
}
int level = (state == Qt::Checked ? Debug::ANY : Debug::NONE);
dispatch(FuncRequest(LFUN_DEBUG_LEVEL_SET, convert<string>(level)));
} else {
Q_FOREACH(LevelButton* button, checked_buttons) {
button->setCheckStatusSilent(Qt::Checked);
}
}
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)
{
#ifdef Q_WS_MACX

View File

@ -34,8 +34,6 @@ class QShowEvent;
namespace lyx {
namespace frontend {
struct LevelButton;
class ProgressViewWidget : public QWidget, public Ui::ProgressViewUi
{
@ -76,19 +74,15 @@ private Q_SLOTS:
void appendText(QString const & text);
void appendLyXErrText(QString const & text);
void clearText();
void levelChanged();
void tristateChanged(int state);
void debugMessageActivated(QTreeWidgetItem *, int);
void debugSelectionChanged();
private:
ProgressViewWidget * widget_;
void levelChanged();
void showEvent(QShowEvent*);
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>
<widget class="QWidget" name="ProgressViewUi" >
<property name="geometry" >
<widget class="QWidget" name="ProgressViewUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,149 +9,179 @@
<height>518</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QTabWidget" name="tabWidget" >
<property name="enabled" >
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy" >
<sizepolicy>
<vsizetype>13</vsizetype>
<hsizetype>7</hsizetype>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="baseSize" >
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops" >
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="layoutDirection" >
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground" >
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="tabPosition" >
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="tabShape" >
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex" >
<property name="currentIndex">
<number>0</number>
</property>
<property name="iconSize" >
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="usesScrollButtons" >
<property name="usesScrollButtons">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab" >
<attribute name="title" >
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Output</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<widget class="QTextEdit" name="outTE" >
<property name="sizePolicy" >
<sizepolicy>
<vsizetype>13</vsizetype>
<hsizetype>7</hsizetype>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTextEdit" name="outTE">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape" >
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow" >
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth" >
<property name="lineWidth">
<number>1</number>
</property>
<property name="readOnly" >
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2" >
<attribute name="title" >
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Settings</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QScrollArea" name="scrollArea" >
<property name="widgetResizable" >
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="sbarCB">
<property name="toolTip">
<string>Display statusbar messages?</string>
</property>
<property name="text">
<string>&amp;Statusbar messages</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>474</height>
</rect>
</widget>
</item>
<item row="0" column="1" rowspan="4">
<widget class="QTreeWidget" name="debugMessagesTW">
<property name="toolTip">
<string>Select the debug messages that should be displayed</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" >
<item>
<layout class="QGridLayout" name="settingsLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="autoClearCB" >
<property name="toolTip" >
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Debug messages</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="debugNoneRB">
<property name="toolTip">
<string>Display no debug messages</string>
</property>
<property name="text">
<string>&amp;None</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="debugSelectedRB">
<property name="toolTip">
<string>Display the debug messages selected to the right</string>
</property>
<property name="text">
<string>S&amp;elected</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="debugAnyRB">
<property name="toolTip">
<string>Display all debug messages</string>
</property>
<property name="text">
<string>&amp;All</string>
</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;Automatic clear</string>
<property name="text">
<string>&amp;Clear automatically</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="sbarCB" >
<property name="text" >
<string>Statusbar messages</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>----- Debugging levels -----</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -161,7 +191,7 @@
</layout>
</widget>
<includes>
<include location="local" >qt_i18n.h</include>
<include location="local">qt_i18n.h</include>
</includes>
<resources/>
<connections/>