Changeset - e246af74222f
[Not reviewed]
default
0 3 0
Hasan Yavuz ÖZDERYA - 9 years ago 2017-04-01 13:27:44
hy@ozderya.net
show tabs when focusing on command panel
3 files changed with 12 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/hidabletabwidget.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2017 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 
@@ -68,12 +68,17 @@ void HidableTabWidget::onTabBarDoubleCli
 

	
 
void HidableTabWidget::connectSignals()
 
{
 
    if (hideAction.isChecked()) // hidden
 
    {
 
        connect(this, SIGNAL(tabBarClicked(int)), this, SLOT(onTabBarClicked()));
 
    }
 
    else // shown
 
    {
 
        connect(this, SIGNAL(tabBarDoubleClicked(int)), this, SLOT(onTabBarDoubleClicked()));
 
    }
 
}
 

	
 
void HidableTabWidget::showTabs()
 
{
 
    hideAction.setChecked(false);
 
}
src/hidabletabwidget.h
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2017 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 
@@ -21,21 +21,24 @@
 
#define HIDABLETABWIDGET_H
 

	
 
#include <QTabWidget>
 
#include <QAction>
 

	
 
class HidableTabWidget : public QTabWidget
 
{
 
    Q_OBJECT
 
public:
 
    explicit HidableTabWidget(QWidget *parent = 0);
 
    QAction hideAction;
 

	
 
public slots:
 
    void showTabs();
 

	
 
private slots:
 
    void onHideAction(bool checked);
 
    void onTabBarClicked();
 
    void onTabBarDoubleClicked();
 

	
 
    void connectSignals();
 
};
 

	
 
#endif // HIDABLETABWIDGET_H
src/mainwindow.cpp
Show inline comments
 
@@ -77,24 +77,25 @@ MainWindow::MainWindow(QWidget *parent) 
 
    ui->tabWidget->setCurrentIndex(0);
 
    auto tbPortControl = portControl.toolBar();
 
    addToolBar(tbPortControl);
 
    addToolBar(recordPanel.toolbar());
 

	
 
    ui->plotToolBar->addAction(snapshotMan.takeSnapshotAction());
 
    ui->menuBar->insertMenu(ui->menuHelp->menuAction(), snapshotMan.menu());
 
    ui->menuBar->insertMenu(ui->menuHelp->menuAction(), commandPanel.menu());
 

	
 
    connect(&commandPanel, &CommandPanel::focusRequested, [this]()
 
            {
 
                this->ui->tabWidget->setCurrentWidget(&commandPanel);
 
                this->ui->tabWidget->showTabs();
 
            });
 

	
 
    tbPortControl->setObjectName("tbPortControl");
 
    ui->plotToolBar->setObjectName("tbPlot");
 

	
 
    setupAboutDialog();
 

	
 
    // init view menu
 
    for (auto a : plotMan->menuActions())
 
    {
 
        ui->menuView->addAction(a);
 
    }
 
@@ -244,24 +245,25 @@ MainWindow::MainWindow(QWidget *parent) 
 
    // ensure command panel has 1 command if none loaded
 
    if (!commandPanel.numOfCommands())
 
    {
 
        commandPanel.newCommandAction()->trigger();
 
    }
 

	
 
    // Important: This should be after newCommandAction is triggered
 
    // (above) we don't want user to be greeted with command panel on
 
    // the very first run.
 
    connect(commandPanel.newCommandAction(), &QAction::triggered, [this]()
 
            {
 
                this->ui->tabWidget->setCurrentWidget(&commandPanel);
 
                this->ui->tabWidget->showTabs();
 
            });
 
}
 

	
 
MainWindow::~MainWindow()
 
{
 
    if (serialPort.isOpen())
 
    {
 
        serialPort.close();
 
    }
 

	
 
    delete plotMan;
 

	
0 comments (0 inline, 0 general)