Changeset - 2f041070d306
[Not reviewed]
default
2 4 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-09-02 00:25:30
hy@ozderya.net
use QToolButton and QAction instead of CustomCheckableButton for Open port button
6 files changed with 8 insertions and 85 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -55,13 +55,12 @@ include_directories(${QWT_INCLUDE_DIR})
 
qt5_wrap_ui(UI_FILES mainwindow.ui portcontrol.ui about_dialog.ui)
 

	
 
add_executable(${PROGRAM_NAME} WIN32
 
  main.cpp
 
  mainwindow.cpp
 
  portcontrol.cpp
 
  customcheckablebutton.cpp
 
  plot.cpp
 
  zoomer.cpp
 
  hidabletabwidget.cpp
 
  framebuffer.cpp
 
  ${UI_FILES}
 
  misc/windows_icon.rc
customcheckablebutton.cpp
Show inline comments
 
deleted file
customcheckablebutton.h
Show inline comments
 
deleted file
portcontrol.cpp
Show inline comments
 
@@ -41,14 +41,13 @@ PortControl::PortControl(QSerialPort* po
 
    portToolBar.addAction(&openAction);
 

	
 
    // setup buttons
 
    QObject::connect(ui->pbReloadPorts, &QPushButton::clicked,
 
                     this, &PortControl::loadPortList);
 

	
 
    QObject::connect(ui->pbOpenPort, &QPushButton::clicked,
 
                     this, &PortControl::togglePort);
 
    ui->pbOpenPort->setDefaultAction(&openAction);
 

	
 
    // TODO: port name coming from combobox is dirty, create a separate layer of signals
 
    //       that will sanitize this information
 
    QObject::connect(ui->cbPortList,
 
                     SELECT<const QString&>::OVERLOAD_OF(&QComboBox::activated),
 
                     this, &PortControl::selectPort);
 
@@ -245,13 +244,12 @@ void PortControl::togglePort()
 
            selectFlowControl((QSerialPort::FlowControl) flowControlButtons.checkedId());
 

	
 
            qDebug() << "Opened port:" << serialPort->portName();
 
            emit portToggled(true);
 
        }
 
    }
 
    ui->pbOpenPort->setChecked(serialPort->isOpen());
 
    openAction.setChecked(serialPort->isOpen());
 
}
 

	
 
void PortControl::selectPort(QString portName)
 
{
 
    // portName may be coming from combobox
portcontrol.ui
Show inline comments
 
@@ -273,13 +273,19 @@
 
     </property>
 
    </spacer>
 
   </item>
 
   <item>
 
    <layout class="QVBoxLayout" name="verticalLayout_4">
 
     <item>
 
      <widget class="CustomCheckableButton" name="pbOpenPort">
 
      <widget class="QToolButton" name="pbOpenPort">
 
       <property name="sizePolicy">
 
        <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
 
         <horstretch>0</horstretch>
 
         <verstretch>0</verstretch>
 
        </sizepolicy>
 
       </property>
 
       <property name="minimumSize">
 
        <size>
 
         <width>0</width>
 
         <height>50</height>
 
        </size>
 
       </property>
 
@@ -318,16 +324,9 @@
 
      </spacer>
 
     </item>
 
    </layout>
 
   </item>
 
  </layout>
 
 </widget>
 
 <customwidgets>
 
  <customwidget>
 
   <class>CustomCheckableButton</class>
 
   <extends>QPushButton</extends>
 
   <header>customcheckablebutton.h</header>
 
  </customwidget>
 
 </customwidgets>
 
 <resources/>
 
 <connections/>
 
</ui>
serialplot.pro
Show inline comments
 
@@ -32,22 +32,20 @@ TEMPLATE = app
 

	
 
CONFIG += qwt
 

	
 

	
 
SOURCES += main.cpp\
 
        mainwindow.cpp \
 
    customcheckablebutton.cpp \
 
    portcontrol.cpp \
 
    plot.cpp \
 
    zoomer.cpp \
 
    hidabletabwidget.cpp \
 
    framebuffer.cpp
 

	
 
HEADERS  += mainwindow.h \
 
    utils.h \
 
    customcheckablebutton.h \
 
    portcontrol.h \
 
    floatswap.h \
 
    plot.h \
 
    zoomer.h \
 
    hidabletabwidget.h \
 
    framebuffer.h
0 comments (0 inline, 0 general)