From 43c2a51331d3e91d86ef50c5262920bdaa260925 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 11 Feb 2019 10:52:30 +0100 Subject: Show/hide drumkit tab depending on if the current kit has a valid image attached or not. --- plugingui/mainwindow.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'plugingui/mainwindow.cc') diff --git a/plugingui/mainwindow.cc b/plugingui/mainwindow.cc index a0364fa..a625bc3 100644 --- a/plugingui/mainwindow.cc +++ b/plugingui/mainwindow.cc @@ -51,8 +51,12 @@ MainWindow::MainWindow(Settings& settings, void* native_window) tabs.setTabWidth(100); tabs.move(16, 0); // x-offset to make room for the left side bar. tabs.addTab("Main", &main_tab); - tabs.addTab("Drumkit", &drumkit_tab); + drumkit_tab_id = tabs.addTab("Drumkit", &drumkit_tab); + changeDrumkitTabVisibility(false); // Hide while no kit is loaded tabs.addTab("About", &about_tab); + + CONNECT(&drumkit_tab, imageChangeNotifier, + this, &MainWindow::changeDrumkitTabVisibility); } MainWindow::~MainWindow() @@ -105,6 +109,16 @@ void MainWindow::sizeChanged(std::size_t width, std::size_t height) tabs.resize(std::max((int)width - 2 * 16, 0), height); } +void MainWindow::changeDrumkitTabVisibility(bool visible) +{ + // TODO: Check if the currently active tab is the drumkit tab and switch to + // the main tab if it is. + + // TODO: Add disabled state to the TabButtons and make it disabled instead of + // hidden here. + tabs.setVisible(drumkit_tab_id, visible); +} + void MainWindow::closeEventHandler() { closing = true; -- cgit v1.2.3