* lazzara/afp/photos/gui/src/main_window.cc, * lazzara/afp/photos/gui/src/main_window.hh: Add shortcuts to navigate quickly. --- milena/sandbox/ChangeLog | 8 ++ .../lazzara/afp/photos/gui/src/main_window.cc | 71 +++++++++++++++----- .../lazzara/afp/photos/gui/src/main_window.hh | 9 ++- 3 files changed, 70 insertions(+), 18 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index 3fec0e3..ba20fec 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,3 +1,11 @@ +2010-03-30 Guillaume Lazzara z@lrde.epita.fr + + Improve the usability of AFP's GUI. + + * lazzara/afp/photos/gui/src/main_window.cc, + * lazzara/afp/photos/gui/src/main_window.hh: Add shortcuts to + navigate quickly. + 2010-03-29 Guillaume Lazzara z@lrde.epita.fr
Add support for more image types. diff --git a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc index 5f4cc20..c421b81 100644 --- a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc +++ b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc @@ -81,6 +81,15 @@ namespace mln this, SLOT(remove_image(bool))); toolbar_->addAction(removeImage);
+ showHiddenImages_ = new QAction(QIcon(":/icons/photos.png"), + tr("Show hidden photos."), + toolbar_); + showHiddenImages_->setCheckable(true); + connect(showHiddenImages_, SIGNAL(toggled(bool)), + this, SLOT(show_hidden_images(bool))); + toolbar_->addAction(showHiddenImages_); + + addToolBar(toolbar_);
@@ -168,13 +177,6 @@ namespace mln ++current_file_; progressBar_.setValue(current_file_);
- tabWidget->setTabText(0, - QString(tr("With text (%1)")) - .arg(withTextListWidget->count())); - tabWidget->setTabText(1, - QString(tr("Without text (%1)")) - .arg(withoutTextListWidget->count())); - if (current_file_ < file_list_.size()) start_process(); else @@ -264,18 +266,24 @@ namespace mln
item->setSizeHint(QSize(170, 200)); withTextListWidget->addItem(item); - // Fixme: update tab title with number of photos. if (withTextListWidget->count() == 1) { withTextListWidget->setCurrentRow(0, QItemSelectionModel::SelectCurrent); - on_withTextListWidget_itemClicked(withTextListWidget->item(0)); + on_withTextListWidget_currentItemChanged(withTextListWidget->item(0)); } } else - // Fixme: update tab title with number of photos. withoutTextListWidget->addItem(item); }
+ // Update tab titles. + tabWidget->setTabText(0, + QString(tr("With text (%1)")) + .arg(withTextListWidget->count())); + tabWidget->setTabText(1, + QString(tr("Without text (%1)")) + .arg(withoutTextListWidget->count())); + next_process(); }
@@ -299,7 +307,7 @@ namespace mln
void - main_window::on_withTextListWidget_itemClicked(QListWidgetItem * item) + main_window::on_withTextListWidget_currentItemChanged(QListWidgetItem * item) { if (fullImageButton->isChecked()) on_fullImageButton_toggled(true); @@ -317,7 +325,7 @@ namespace mln }
void - main_window::on_withoutTextListWidget_itemClicked(QListWidgetItem * item) + main_window::on_withoutTextListWidget_currentItemChanged(QListWidgetItem * item) { display_image(file_list_.at(item->data(Qt::UserRole).toInt()).absoluteFilePath()); } @@ -380,7 +388,7 @@ namespace mln if (withoutTextListWidget->count()) { withoutTextListWidget->setCurrentRow(0, QItemSelectionModel::Select); - on_withoutTextListWidget_itemClicked(withoutTextListWidget->item(0)); + on_withoutTextListWidget_currentItemChanged(withoutTextListWidget->item(0)); } } } @@ -401,10 +409,41 @@ namespace mln { QList<QListWidgetItem *> items = withTextListWidget->selectedItems(); foreach(QListWidgetItem *item, items) - delete withTextListWidget->takeItem(withTextListWidget->row(item)); + { + hidden_.insert(item); + if (! showHiddenImages_->isChecked()) + item->setHidden(true); + }
- if (withTextListWidget->count()) - withTextListWidget->setCurrentRow(0, QItemSelectionModel::Select); + update_withtext_count(); +// if (withTextListWidget->count()) +// withTextListWidget->setCurrentRow(0, QItemSelectionModel::Select); + } + + + void + main_window::show_hidden_images(bool b) + { + foreach(QListWidgetItem *item, hidden_) + item->setHidden(! b); + + update_withtext_count(); +// if (withTextListWidget->count()) +// withTextListWidget->setCurrentRow(0, QItemSelectionModel::Select); + } + + + void + main_window::update_withtext_count() + { + unsigned count; + if (! showHiddenImages_->isChecked()) + count = withTextListWidget->count() - hidden_.size(); + else + count = withTextListWidget->count(); + tabWidget->setTabText(0, + QString(tr("With text (%1)")) + .arg(count)); }
diff --git a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh index eb6f008..5b42d41 100644 --- a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh +++ b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh @@ -48,8 +48,8 @@ namespace mln void process__error_slot(QProcess::ProcessError); void process__finished_slot(int exitCode, QProcess::ExitStatus exitStatus); - void on_withTextListWidget_itemClicked(QListWidgetItem * item); - void on_withoutTextListWidget_itemClicked(QListWidgetItem * item); + void on_withTextListWidget_currentItemChanged(QListWidgetItem * item); + void on_withoutTextListWidget_currentItemChanged(QListWidgetItem * item);
void on_fullImageButton_toggled(bool b); void on_textBoxesButton_toggled(bool); @@ -63,6 +63,7 @@ namespace mln void cancel_clicked(bool);
void remove_image(bool); + void show_hidden_images(bool b);
signals: void process_finished(); @@ -82,12 +83,15 @@ namespace mln
void connect_process();
+ void update_withtext_count(); + private: // Attributes QString output_dir_; QDir dir_; QString text_in_photo_ppm_; QProcess process_; QString options_; + QSet<QListWidgetItem *> hidden_;
QFileInfoList file_list_; int current_file_; @@ -99,6 +103,7 @@ namespace mln
// ToolBar QToolBar *toolbar_; + QAction *showHiddenImages_; };