Commit 1f5268f3 authored by Arthur Crepin-Leblond's avatar Arthur Crepin-Leblond Committed by Guillaume Lazzara
Browse files

Add shortcuts in Qt interface.

        * demo/viewer/browser_widget.cc: Change arrows icon.
        * demo/viewer/help_dialog.cc: Add more informations.
        * demo/viewer/key_widget.cc,
        * demo/viewer/key_widget.hh: Add setAll(bool).
        * demo/viewer/viewer.cc,
        * demo/viewer/viewer.hh: Add shortcuts.
parent e91a1885
2010-08-06 Arthur Crepin-Leblond <crepin@lrde.epita.fr>
Add shortcuts in Qt interface.
* demo/viewer/browser_widget.cc: Change arrows icon.
* demo/viewer/help_dialog.cc: Add more informations.
* demo/viewer/key_widget.cc,
* demo/viewer/key_widget.hh: Add setAll(bool).
* demo/viewer/viewer.cc,
* demo/viewer/viewer.hh: Add shortcuts.
2010-08-04 Arthur Crepin-Leblond <crepin@ptaouchnok.lrde.epita.fr>
Fix bug in Qt interface.
......
......@@ -33,8 +33,9 @@ BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
{
QToolButton* next= new QToolButton();
QToolButton* prev= new QToolButton();
next->setArrowType(Qt::RightArrow);
prev->setArrowType(Qt::LeftArrow);
prev->setIcon(style()->standardIcon(QStyle::SP_ArrowLeft));
next->setIcon(style()->standardIcon(QStyle::SP_ArrowRight));
QLabel* title = new QLabel(tr("Images"));
title->setAlignment(Qt::AlignHCenter);
......
......@@ -40,10 +40,15 @@ HelpDialog::HelpDialog()
"Document layout viewer:\n"
"\n"
"Usage:\n"
" - Choose an image file in the file browser\n"
" - If the document layout is present\n"
" (XML file with the same name),\n"
" select regions to display their properties.\n"
" - Choose an image file in the file browser,\n"
"if XML file(s) whose prefix name is the same as\n"
"the image name (i.e.image _name(_ .*)?.xml) is present\n"
"then you can choose the one you want in the step\n"
"chooser to display it on the scene.\n"
"- To load a base 64 encoded XML file,\n"
"its extension has to be .xmlc otherwise \n"
"the program won't recognize it !\n"
" - Select regions to display their properties.\n"
" - Use the mouse or keyboard to move and zoom\n"
" (Arrows, PageUp, PageDown, Home, End).\n"
"\n");
......
......@@ -39,9 +39,10 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map)
items_->setHeaderHidden(true);
text_->setCheckState(0, Qt::Checked);
text_->setExpanded(true);
regions_->setCheckState(0, Qt::Checked);
regions_->setExpanded(true);
text_->setExpanded(true);
for (int i = 0; i < 3; ++i)
add_item_(key_map.at(i).first, key_map.at(i).second,
......@@ -70,6 +71,18 @@ void KeyWidget::update_all()
update(regions_->child(i));
}
void KeyWidget::setAll(bool b)
{
Qt::CheckState state;
if (b)
state = Qt::Checked;
else
state = Qt::Unchecked;
text_->setCheckState(0, state);
regions_->setCheckState(0, state);
}
void KeyWidget::setAllCheck(QTreeWidgetItem* parent)
{
for (int i = 0; i < parent->childCount(); ++i)
......
......@@ -45,6 +45,9 @@ public:
signals:
void updated(int key, bool checked);
public slots:
void setAll(bool b);
private slots:
void change_mode(bool b);
void update(QTreeWidgetItem* item);
......
......@@ -87,74 +87,94 @@ Viewer::Viewer(int &argc, char** argv)
win_->statusBar();
QMenu* file_menu = win_->menuBar()->addMenu(tr("File"));
QAction* quit_action = new QAction(tr("Quit"), file_menu);
QMenu* option_menu = win_->menuBar()->addMenu(tr("Options"));
QMenu* help_menu = win_->menuBar()->addMenu(tr("Help"));
QAction* quit_action = create_action("Quit", file_menu,
"Exit the program.", "Ctrl+q");
connect(quit_action, SIGNAL(triggered()),
app_, SLOT(quit()));
quit_action->setStatusTip(tr("Exit the program."));
file_menu->addAction(quit_action);
QMenu* option_menu = win_->menuBar()->addMenu(tr("Options"));
outline_action_ = new QAction(tr("Draw outline"), option_menu);
outline_action_->setStatusTip(tr("Draw region outlines."));
outline_action_ = create_action("Draw outline", option_menu,
"Draw region outlines.", "Ctrl+o");
outline_action_->setCheckable(true);
outline_action_->setChecked(true);
connect(outline_action_, SIGNAL(toggled(bool)),
this, SIGNAL(setOutline(bool)));
option_menu->addAction(outline_action_);
precise_action_ = new QAction(tr("Precise outline"), option_menu);
precise_action_->setStatusTip(tr("1px outline relative to the image "
"(1px relative to the view if off)."));
precise_action_ = create_action("Precise outline", option_menu,
"1px outline relative to the image "
"(1px relative to the view if off).",
"Ctrl+p");
precise_action_->setCheckable(true);
precise_action_->setChecked(false);
connect(precise_action_, SIGNAL(toggled(bool)),
this, SIGNAL(setPrecise(bool)));
option_menu->addAction(precise_action_);
fill_action_ = new QAction(tr("Fill regions"), option_menu);
fill_action_->setStatusTip(tr("Color the inside of regions."));
fill_action_ = create_action("Fill regions", option_menu,
"Color the inside of regions.", "Ctrl+f");
fill_action_->setCheckable(true);
fill_action_->setChecked(true);
connect(fill_action_, SIGNAL(toggled(bool)),
this, SIGNAL(setFill(bool)));
option_menu->addAction(fill_action_);
QAction* cache_action = new QAction(tr("Disable cache"), file_menu);
cache_action->setStatusTip(tr("Disable the image cache (useful for"
" large images)."));
QAction* cache_action = create_action("Disable cache", option_menu,
"Disable the image cache (useful for"
" large images).", "Ctrl+c");
cache_action->setCheckable(true);
cache_action->setChecked(false);
connect(cache_action, SIGNAL(toggled(bool)),
this, SLOT(useCache(bool)));
option_menu->addAction(cache_action);
QAction* extended_action = new QAction(tr("Extended mode"), file_menu);
extended_action->setStatusTip(tr("If enabled, some features not supported by ICDAR"
" are added such as text regions or text lines"));
QAction* extended_action = create_action("Extended mode", option_menu,
"If enabled, some features "
"not supported by ICDAR"
" are added such as text regions"
"or text lines", "Ctrl+e");
extended_action->setCheckable(true);
extended_action->setChecked(false);
connect(extended_action, SIGNAL(toggled(bool)),
this, SLOT(useExtended(bool)));
option_menu->addAction(extended_action);
QAction* show_image_action = new QAction(tr("Show pictures"), file_menu);
//show_image_action->setStatusTip(tr(""));
QAction* show_image_action = create_action("Show pictures", option_menu,
"Display pictures on the scene or not",
"Ctrl+i");
show_image_action->setCheckable(true);
show_image_action->setChecked(true);
connect(show_image_action, SIGNAL(toggled(bool)),
this, SLOT(useImage(bool)));
option_menu->addAction(show_image_action);
QAction* show_text_action = new QAction(tr("Show text"), file_menu);
show_text_action->setStatusTip(tr("Show detected text inside boxes."));
QAction* show_text_action = create_action("Show text", option_menu,
"Show detected text inside boxes.",
"Ctrl+t");
show_text_action->setCheckable(true);
show_text_action->setChecked(true);
connect(show_text_action, SIGNAL(toggled(bool)),
this, SLOT(useText(bool)));
option_menu->addAction(show_text_action);
QMenu* help_menu = win_->menuBar()->addMenu(tr("Help"));
QAction* about_action = new QAction(tr("About"), help_menu);
about_action->setStatusTip(tr("About this program."));
key_wgt_ = new KeyWidget(key_map_);
QAction *show_region_action = create_action("Show regions", option_menu,
"Display regions that are present in"
" the XML file.",
"Ctrl+r");
show_region_action->setCheckable(true);
show_region_action->setChecked(true);
connect(show_region_action, SIGNAL(toggled(bool)),
key_wgt_, SLOT(setAll(bool)));
option_menu->addAction(show_region_action);
QAction* about_action = create_action("About", help_menu,
"About this program",
"Ctrl+h");
connect(about_action, SIGNAL(triggered()),
this, SLOT(help()));
help_menu->addAction(about_action);
......@@ -167,7 +187,6 @@ Viewer::Viewer(int &argc, char** argv)
XmlWidget* xml_wgt = new XmlWidget();
BrowserWidget* browser_wgt =
new BrowserWidget(files_, argc != 2 ? QString() : argv[1]);
key_wgt_ = new KeyWidget(key_map_);
ImageWidget* image_wgt = new ImageWidget(scene_);
scene_->setBackgroundBrush(scene_->palette().window());
......@@ -276,6 +295,7 @@ Viewer::add_text(QDomNode line, QDomNode region)
QGraphicsTextItem* text_item = scene_->addText(text, font);
text_item->setPos(x_min, y_min);
text_item->setTextInteractionFlags(Qt::TextSelectableByMouse);
text_item->setZValue(5);
text_vector_ << text_item;
if (!text_)
scene_->removeItem(text_item);
......@@ -441,8 +461,8 @@ Viewer::load_xml(QString filename)
}
}
if ((extended_mode_ || text_) &&
region.toElement().tagName().contains("text_region"))
// if ((extended_mode_ || text_) &&
if (region.toElement().tagName().contains("text_region"))
{
QDomNode para = region.firstChild();
while (!para.isNull() && !para.toElement().tagName().contains("paragraph"))
......@@ -656,3 +676,14 @@ Viewer::change_base(bool b)
{
base64_ = b;
}
QAction
*Viewer::create_action(QString name, QMenu *menu, QString status, QString shortcut)
{
QAction* action = new QAction(name, menu);
action->setStatusTip(status);
action->setShortcut(QKeySequence(shortcut));
return (action);
}
......@@ -77,6 +77,7 @@ private:
QPixmap load_base64(QString xml);
void add_region(QDomNode father, QString attr_id);
void add_text(QDomNode line, QDomNode region);
QAction *create_action(QString name, QMenu* menu, QString status, QString shortcut);
QApplication* app_;
QMainWindow* win_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment