---
milena/sandbox/lazzara/afp/photos/gui/gui.pro | 2 +
.../lazzara/afp/photos/gui/src/main_window.cc | 50 +++++++++++++++-----
.../lazzara/afp/photos/gui/src/main_window.hh | 5 ++
.../lazzara/afp/photos/gui/ui/main_window.ui | 20 ++++----
4 files changed, 55 insertions(+), 22 deletions(-)
diff --git a/milena/sandbox/lazzara/afp/photos/gui/gui.pro
b/milena/sandbox/lazzara/afp/photos/gui/gui.pro
index 41b8006..7c6aa8e 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/gui.pro
+++ b/milena/sandbox/lazzara/afp/photos/gui/gui.pro
@@ -9,6 +9,8 @@ INCLUDEPATH += . src
CONFIG += release
+QMAKE_CXXFLAGS = -g
+
# Input
HEADERS += src/main_window.hh src/custom_delegate.hh src/launch_dialog.hh
FORMS += ui/main_window.ui ui/launch_dialog.ui
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 c421b81..c1d92c1 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc
+++ b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc
@@ -152,8 +152,10 @@ namespace mln
file_list_ = dir_.entryInfoList();
current_file_ = 0;
+
withTextListWidget->clear();
withoutTextListWidget->clear();
+ update_tab_title();
progressToolBar_->show();
progressLabel_.setText(tr("Processing images..."));
@@ -276,13 +278,8 @@ namespace mln
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()));
+ // Update tab title.
+ update_tab_title();
next_process();
}
@@ -307,8 +304,17 @@ namespace mln
void
+ main_window::on_withTextListWidget_itemClicked(QListWidgetItem * item)
+ {
+ on_withTextListWidget_currentItemChanged(item);
+ }
+
+ void
main_window::on_withTextListWidget_currentItemChanged(QListWidgetItem * item)
{
+ if (!withTextListWidget->count())
+ return;
+
if (fullImageButton->isChecked())
on_fullImageButton_toggled(true);
else if (textOnlyButton->isChecked())
@@ -325,15 +331,22 @@ namespace mln
}
void
+ main_window::on_withoutTextListWidget_itemClicked(QListWidgetItem * item)
+ {
+ on_withoutTextListWidget_currentItemChanged(item);
+ }
+
+ void
main_window::on_withoutTextListWidget_currentItemChanged(QListWidgetItem * item)
{
-
display_image(file_list_.at(item->data(Qt::UserRole).toInt()).absoluteFilePath());
+ if (withoutTextListWidget->count() && item)
+ display_image(file_list_.at(item->data(Qt::UserRole).toInt()).absoluteFilePath());
}
void
main_window::on_fullImageButton_toggled(bool)
{
- if (withTextListWidget->count())
+ if (withTextListWidget->count() &&
withTextListWidget->currentItem())
{
QString filename =
file_list_.at(withTextListWidget->currentItem()->data(Qt::UserRole).toInt()).absoluteFilePath();
display_image(filename);
@@ -343,7 +356,7 @@ namespace mln
void
main_window::on_textBoxesButton_toggled(bool)
{
- if (withTextListWidget->count())
+ if (withTextListWidget->count() &&
withTextListWidget->currentItem())
{
QFileInfo f(withTextListWidget->currentItem()->text());
display_image(textBoxes_file(f.baseName()));
@@ -353,7 +366,7 @@ namespace mln
void
main_window::on_textMaskButton_toggled(bool)
{
- if (withTextListWidget->count())
+ if (withTextListWidget->count() &&
withTextListWidget->currentItem())
{
QFileInfo f(withTextListWidget->currentItem()->text());
display_image(textMask_file(f.baseName()));
@@ -363,7 +376,7 @@ namespace mln
void
main_window::on_textOnlyButton_toggled(bool)
{
- if (withTextListWidget->count())
+ if (withTextListWidget->count() &&
withTextListWidget->currentItem())
{
QFileInfo f(withTextListWidget->currentItem()->text());
display_image(output_file(f.baseName()));
@@ -493,6 +506,19 @@ namespace mln
event->ignore();
}
+
+ void
+ main_window::update_tab_title()
+ {
+ tabWidget->setTabText(0,
+ QString(tr("With text (%1)"))
+ .arg(withTextListWidget->count()));
+ tabWidget->setTabText(1,
+ QString(tr("Without text (%1)"))
+ .arg(withoutTextListWidget->count()));
+ }
+
+
} // end of namespace scribo::demo
} // end of namespace scribo
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 5b42d41..6732f29 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh
+++ b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh
@@ -48,7 +48,10 @@ 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_withTextListWidget_currentItemChanged(QListWidgetItem * item);
+ void on_withoutTextListWidget_itemClicked(QListWidgetItem * item);
void on_withoutTextListWidget_currentItemChanged(QListWidgetItem * item);
void on_fullImageButton_toggled(bool b);
@@ -65,6 +68,8 @@ namespace mln
void remove_image(bool);
void show_hidden_images(bool b);
+ void update_tab_title();
+
signals:
void process_finished();
diff --git a/milena/sandbox/lazzara/afp/photos/gui/ui/main_window.ui
b/milena/sandbox/lazzara/afp/photos/gui/ui/main_window.ui
index 0d3d925..4162d98 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/ui/main_window.ui
+++ b/milena/sandbox/lazzara/afp/photos/gui/ui/main_window.ui
@@ -212,18 +212,18 @@
</widget>
<widget class="QDockWidget" name="dockWidget" >
<property name="sizePolicy" >
- <sizepolicy vsizetype="Maximum" hsizetype="Maximum" >
+ <sizepolicy vsizetype="Maximum" hsizetype="Expanding"
>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="maximumSize" >
- <size>
- <width>550</width>
- <height>524287</height>
- </size>
- </property>
<widget class="QWidget" name="dockWidgetContents" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Expanding"
>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<layout class="QVBoxLayout" name="verticalLayout_7"
>
@@ -256,7 +256,7 @@
<item>
<widget class="QGraphicsView" name="graphicsView"
>
<property name="sizePolicy" >
- <sizepolicy vsizetype="Expanding"
hsizetype="Maximum" >
+ <sizepolicy vsizetype="Expanding"
hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -269,7 +269,7 @@
</property>
<property name="maximumSize" >
<size>
- <width>512</width>
+ <width>16777215</width>
<height>512</height>
</size>
</property>
@@ -496,7 +496,7 @@
<x>0</x>
<y>0</y>
<width>708</width>
- <height>31</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
--
1.5.6.5