WSL/SLF GitLab Repository

Commit c545a53b authored by Michael Reisecker's avatar Michael Reisecker
Browse files

Workflow can now be toggled instead of show/hide

This gets rid of an inconsistency where on macOS CMD+H was
already reserved for hiding the window. It's nicer anyway
and we get rid of an almost empty menu ("window").
parent 26f59437
......@@ -22,6 +22,7 @@ Releases of the INIshell project will be documented in this file.
Standard "reset", "save" and "clear" buttons (in addition to cmd line)
- Display sections for missing INI keys
- Jump to 1st missing input value if saving is cancelled
- Workflow panel is now toggled instead of separate show/hide menus
### Fixed
......
......@@ -110,8 +110,10 @@ QList<int> MainPanel::getSplitterSizes() const
/**
* @brief Set sizes of the panels the splitter manages.
* @param[in] sizes The sizes the splitter should give to its panels.
* @param[in] enforce_visible Show the workflow with default size if its size is saved
* to be zero?
*/
void MainPanel::setSplitterSizes(QList<int> sizes)
void MainPanel::setSplitterSizes(QList<int> sizes, bool enforce_visible)
{
splitter_->setStretchFactor(0, Cst::proportion_workflow_horizontal_percent);
splitter_->setStretchFactor(1, 100 - Cst::proportion_workflow_horizontal_percent);
......@@ -122,7 +124,7 @@ void MainPanel::setSplitterSizes(QList<int> sizes)
bool workflow_success, main_success;
const int width_workflow = getSetting("auto::sizes::splitter_workflow", "size").toInt(&workflow_success);
const int width_mainpanel = getSetting("auto::sizes::splitter_mainpanel", "size").toInt(&main_success);
if (workflow_success && main_success)
if (workflow_success && main_success && workflow_success && !(enforce_visible && width_workflow < 20) )
splitter_->setSizes(sizes << width_workflow << width_mainpanel);
else //reset to default
splitter_->setSizes(QList<int>( {Cst::width_inishell_default * Cst::proportion_workflow_horizontal_percent / 100,
......
......@@ -49,7 +49,7 @@ class MainPanel : public QWidget {
QString setIniValuesFromGui(INIParser *ini);
void displayInfo();
QList<int> getSplitterSizes() const;
void setSplitterSizes(QList<int> sizes = QList<int>());
void setSplitterSizes(QList<int> sizes = QList<int>(), bool enforce_visible = false);
void clearGuiElements();
void clearGui(const bool &set_default = true);
SectionTab * getSectionTab() const noexcept { return section_tab_; }
......
......@@ -815,12 +815,15 @@ void MainWindow::createMenu()
menu_view->addAction(view_log);
connect(view_log, &QAction::triggered, this, &MainWindow::viewLogger);
view_log->setShortcut(Qt::CTRL + Qt::Key_L);
auto *window_toggle_workflow = new QAction(tr("Toggle wor&kflow"), menu_view);
menu_view->addAction(window_toggle_workflow);
connect(window_toggle_workflow, &QAction::triggered, this, &MainWindow::toggleWorkflow);
window_toggle_workflow->setShortcut(Qt::CTRL + Qt::Key_K);
auto *view_refresh = new QAction(tr("&Refresh Applications"), menu_view);
menu_view->addAction(view_refresh);
connect(view_refresh, &QAction::triggered, this,
[=]{ control_panel_->getWorkflowPanel()->scanFoldersForApps(); });
view_refresh->setShortcut(QKeySequence::Refresh);
menu_view->addSeparator();
auto *view_settings = new QAction(getIcon("preferences-system"), tr("&Settings"), menu_view);
view_settings->setMenuRole(QAction::PreferencesRole);
......@@ -832,17 +835,6 @@ void MainWindow::createMenu()
#else
view_settings->setShortcut(Qt::Key_F3);
#endif
/* WINDOW menu */
QMenu *menu_window = this->menuBar()->addMenu(tr("&Window"));
menu_window->addSeparator();
auto *window_show_workflow = new QAction(tr("Show wor&kflow"), menu_window);
menu_window->addAction(window_show_workflow);
connect(window_show_workflow, &QAction::triggered, this, &MainWindow::showWorkflow);
window_show_workflow->setShortcut(Qt::CTRL + Qt::Key_K);
auto *window_hide_workflow = new QAction(tr("&Hide workflow"), menu_window);
menu_window->addAction(window_hide_workflow);
connect(window_hide_workflow, &QAction::triggered, this, &MainWindow::hideWorkflow);
window_hide_workflow->setShortcut(Qt::CTRL + Qt::Key_H);
#ifdef DEBUG
/* DEBUG menu */
......@@ -1096,24 +1088,17 @@ void MainWindow::viewSettings()
}
/**
* @brief Show the workflow panel in case it is collapsed.
* @brief Toggle showing the workflow panel.
*/
void MainWindow::showWorkflow()
void MainWindow::toggleWorkflow()
{
control_panel_->setSplitterSizes(QList<int>( ));
const QList<int> sizes( control_panel_->getSplitterSizes());
if (sizes.at(0) < 20) //Workflow was dragged to 0 before collapsing - make visible again
//the splitter has size constraints so we can just set something big:
control_panel_->setSplitterSizes(QList<int>( {this->width() / 2, this->width() / 2} ));
}
/**
* @brief Hide the workflow panel.
*/
void MainWindow::hideWorkflow()
{
setSplitterSizeSettings();
control_panel_->setSplitterSizes(QList<int>( {0, this->width()} ));
if (sizes.at(0) < 20) { //show
control_panel_->setSplitterSizes(QList<int>( ), true);
} else { //hide
setSplitterSizeSettings();
control_panel_->setSplitterSizes(QList<int>( {0, this->width()} ));
}
}
/**
......
......@@ -151,8 +151,7 @@ class MainWindow : public QMainWindow {
void quitProgram();
void resetGui();
void viewSettings();
void showWorkflow();
void hideWorkflow();
void toggleWorkflow();
void toolbarClick(const QString &function);
void onAutoloadCheck(const int &state);
void onToolbarContextMenuRequest(const QPoint &pos);
......
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