Commit b826d415 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Fix few bugs.

parent 32401e08
......@@ -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
......
......@@ -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();
}
......@@ -306,9 +303,18 @@ 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())
......@@ -324,16 +330,23 @@ 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
......
......@@ -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();
......
......@@ -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" >
......
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