Changeset - c8ad43700b6a
[Not reviewed]
snapshots
0 3 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-09-30 03:25:59
hy@ozderya.net
refactored mainwindow to use plot menu items from Plot.menuActions
3 files changed with 10 insertions and 71 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -66,6 +66,12 @@ MainWindow::MainWindow(QWidget *parent) 
 

	
 
    setupAboutDialog();
 

	
 
    // init view menu
 
    for (auto a : ui->plot->menuActions())
 
    {
 
        ui->menuView->addAction(a);
 
    }
 

	
 
    // init UI signals
 

	
 
    // menu signals
 
@@ -78,24 +84,6 @@ MainWindow::MainWindow(QWidget *parent) 
 
    QObject::connect(ui->actionQuit, &QAction::triggered,
 
                     this, &MainWindow::close);
 

	
 
    QObject::connect(ui->actionGrid, &QAction::toggled, [this](bool show)
 
                     {
 
                         ui->plot->showGrid(show);
 
                         ui->actionMinorGrid->setEnabled(show);
 
                     });
 

	
 
    ui->actionMinorGrid->setEnabled(ui->actionGrid->isChecked());
 
    QObject::connect(ui->actionMinorGrid, &QAction::toggled,
 
                     ui->plot, &Plot::showMinorGrid);
 

	
 
    QObject::connect(ui->actionUnzoom, &QAction::triggered,
 
                     ui->plot, &Plot::unzoom);
 

	
 
    QObject::connect(ui->actionDarkBackground, &QAction::toggled,
 
                     ui->plot, &Plot::darkBackground);
 

	
 
    ui->plot->darkBackground(ui->actionDarkBackground->isChecked());
 

	
 
    // port control signals
 
    QObject::connect(&portControl, &PortControl::portToggled,
 
                     this, &MainWindow::onPortToggled);
 
@@ -169,10 +157,6 @@ MainWindow::MainWindow(QWidget *parent) 
 
    ui->plot->setAxis(ui->cbAutoScale->isChecked(),
 
                      ui->spYmin->value(), ui->spYmax->value());
 

	
 
    // init grid
 
    ui->plot->showGrid(ui->actionGrid->isChecked());
 
    ui->plot->showMinorGrid(ui->actionMinorGrid->isChecked());
 

	
 
    // init scale range preset list
 
    for (int nbits = 8; nbits <= 24; nbits++) // signed binary formats
 
    {
mainwindow.ui
Show inline comments
 
@@ -483,10 +483,6 @@
 
    <property name="title">
 
     <string>View</string>
 
    </property>
 
    <addaction name="actionGrid"/>
 
    <addaction name="actionMinorGrid"/>
 
    <addaction name="actionUnzoom"/>
 
    <addaction name="actionDarkBackground"/>
 
   </widget>
 
   <addaction name="menuFile"/>
 
   <addaction name="menuView"/>
 
@@ -560,50 +556,6 @@
 
    <string>Ctrl+Q</string>
 
   </property>
 
  </action>
 
  <action name="actionGrid">
 
   <property name="checkable">
 
    <bool>true</bool>
 
   </property>
 
   <property name="text">
 
    <string>Grid</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Show/hide grid</string>
 
   </property>
 
   <property name="shortcut">
 
    <string>G</string>
 
   </property>
 
  </action>
 
  <action name="actionUnzoom">
 
   <property name="text">
 
    <string>UnZoom</string>
 
   </property>
 
  </action>
 
  <action name="actionMinorGrid">
 
   <property name="checkable">
 
    <bool>true</bool>
 
   </property>
 
   <property name="text">
 
    <string>Minor Grid</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Show/hide minor grid</string>
 
   </property>
 
   <property name="shortcut">
 
    <string>M</string>
 
   </property>
 
  </action>
 
  <action name="actionDarkBackground">
 
   <property name="checkable">
 
    <bool>true</bool>
 
   </property>
 
   <property name="text">
 
    <string>Dark Background</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Toggle Dark Background</string>
 
   </property>
 
  </action>
 
 </widget>
 
 <layoutdefault spacing="6" margin="11"/>
 
 <customwidgets>
plot.cpp
Show inline comments
 
@@ -42,6 +42,7 @@ Plot::Plot(QWidget* parent) :
 
    rectItem.setRect(QRectF(0,0,100,1));
 
    // rectItem.attach(this);
 

	
 
    showGrid(false);
 
    darkBackground(false);
 

	
 
    _showGridAction.setToolTip("Show Grid");
 
@@ -56,10 +57,12 @@ Plot::Plot(QWidget* parent) :
 
    _showMinorGridAction.setCheckable(true);
 
    _darkBackgroundAction.setCheckable(true);
 

	
 
    _showGridAction.setChecked(true);
 
    _showGridAction.setChecked(false);
 
    _showMinorGridAction.setChecked(false);
 
    _darkBackgroundAction.setChecked(false);
 

	
 
    _showMinorGridAction.setEnabled(false);
 

	
 
    connect(&_showGridAction, SELECT<bool>::OVERLOAD_OF(&QAction::triggered),
 
            this, &Plot::showGrid);
 
    connect(&_showGridAction, SELECT<bool>::OVERLOAD_OF(&QAction::triggered),
0 comments (0 inline, 0 general)