GUI: job queue: show "move up/down" buttons if enabled in preferences

Implements the second half of #2060.
This commit is contained in:
Moritz Bunkus 2017-07-31 21:18:41 +02:00
parent 40af013949
commit f212463f76
4 changed files with 113 additions and 28 deletions

View File

@ -15,7 +15,9 @@
tracks will be used for setting the destination file name. Other files that
are added are ignore. Implements the rest of #2058.
* MKVToolNix GUI: job queue: selected jobs can now be move up and down by
pressing the `Ctrl+Up` and `Ctrl+Down` keys. Implements part of #2060.
pressing the `Ctrl+Up` and `Ctrl+Down` keys. Additionally, push buttons to
move them up & down are shown if the corresponding option is enabled in the
preferences. Implements #2060.
## Bug fixes

View File

@ -34,6 +34,8 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="mtx::gui::Util::BasicTreeView" name="jobs">
<property name="contextMenuPolicy">
@ -62,6 +64,61 @@
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="moveJobsButtons" native="true">
<layout class="QVBoxLayout" name="verticalLayout_1">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="moveJobsUp">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qt_resources.qrc">
<normaloff>:/icons/16x16/arrow-up.png</normaloff>:/icons/16x16/arrow-up.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveJobsDown">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qt_resources.qrc">
<normaloff>:/icons/16x16/arrow-down.png</normaloff>:/icons/16x16/arrow-down.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
@ -72,7 +129,9 @@
<header>mkvtoolnix-gui/util/basic_tree_view.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../../qt_resources.qrc"/>
</resources>
<connections/>
<slots>
<slot>onContextMenu(QPoint)</slot>

View File

@ -73,6 +73,8 @@ void
Tool::setupUi() {
ui->jobs->setModel(m_model);
setupMoveJobsButtons();
Util::preventScrollingWithoutFocus(this);
Util::HeaderViewManager::create(*ui->jobs, "Jobs::Jobs");
@ -135,18 +137,29 @@ Tool::setupActions() {
connect(m_editAndRemoveAction, &QAction::triggered, this, &Tool::onEditAndRemove);
connect(m_startImmediatelyAction, &QAction::triggered, this, &Tool::onStartImmediately);
connect(ui->jobs->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Tool::enableMoveJobsButtons);
connect(ui->jobs, &Util::BasicTreeView::doubleClicked, this, &Tool::onViewOutput);
connect(ui->jobs, &Util::BasicTreeView::customContextMenuRequested, this, &Tool::onContextMenu);
connect(ui->jobs, &Util::BasicTreeView::deletePressed, this, &Tool::onRemove);
connect(ui->jobs, &Util::BasicTreeView::ctrlDownPressed, this, [this]() { moveJobsUpOrDown(false); });
connect(ui->jobs, &Util::BasicTreeView::ctrlUpPressed, this, [this]() { moveJobsUpOrDown(true); });
connect(ui->moveJobsDown, &QPushButton::clicked, this, [this]() { moveJobsUpOrDown(false); });
connect(ui->moveJobsUp, &QPushButton::clicked, this, [this]() { moveJobsUpOrDown(true); });
connect(mw, &MainWindow::preferencesChanged, this, &Tool::retranslateUi);
connect(mw, &MainWindow::preferencesChanged, this, &Tool::setupMoveJobsButtons);
connect(mw, &MainWindow::aboutToClose, m_model, &Model::saveJobs);
connect(MainWindow::watchCurrentJobTab(), &WatchJobs::Tab::watchCurrentJobTabCleared, m_model, &Model::resetTotalProgress);
}
void
Tool::setupMoveJobsButtons() {
ui->moveJobsButtons->setVisible(Util::Settings::get().m_showMoveUpDownButtons);
enableMoveJobsButtons();
}
void
Tool::onJobQueueMenu() {
auto mwUi = MainWindow::getUi();
@ -550,4 +563,13 @@ Tool::selectJobs(QList<Job *> const &jobs) {
ui->jobs->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect);
}
void
Tool::enableMoveJobsButtons() {
auto hasSelected = false;
m_model->withSelectedJobsAsList(ui->jobs, [&hasSelected](auto const &selectedJobs) { hasSelected = !selectedJobs.isEmpty(); });
ui->moveJobsUp->setEnabled(hasSelected);
ui->moveJobsDown->setEnabled(hasSelected);
}
}}}

View File

@ -66,6 +66,8 @@ public slots:
void onJobQueueMenu();
void onContextMenu(QPoint pos);
void moveJobsUpOrDown(bool up);
void setupMoveJobsButtons();
void enableMoveJobsButtons();
void resizeColumnsToContents() const;