]> sigrok.org Git - pulseview.git/commitdiff
Replaced mainwindow.ui XML with code
authorJoel Holdsworth <redacted>
Sun, 8 Jul 2012 09:31:50 +0000 (10:31 +0100)
committerJoel Holdsworth <redacted>
Mon, 3 Sep 2012 12:59:06 +0000 (13:59 +0100)
CMakeLists.txt
mainwindow.cpp
mainwindow.h
mainwindow.ui [deleted file]

index 7e13714514242d8c5eecf9b7249e6366718a5783..5f99a4bb7d41eae2b032135f859855d409be4f96 100644 (file)
@@ -39,7 +39,6 @@ set(sigrok-qt2_HEADERS
 
 set(sigrok-qt2_FORMS
        about.ui
-       mainwindow.ui
 )
 
 set(sigrok-qt2_RESOURCES
index 3390e183e0b4b89617f6abdfa88b6fab6b650ae8..d827e2dc8b25db5f597fff6cc106795e8b5000bf 100644 (file)
@@ -22,12 +22,18 @@ extern "C" {
 #include <sigrokdecode.h>
 }
 
+#include <QAction>
+#include <QApplication>
+#include <QButtonGroup>
 #include <QFileDialog>
+#include <QMenu>
+#include <QMenuBar>
+#include <QStatusBar>
+#include <QVBoxLayout>
+#include <QWidget>
 
 #include "about.h"
-
 #include "mainwindow.h"
-#include "ui_mainwindow.h"
 #include "samplingbar.h"
 #include "sigview.h"
 
@@ -42,23 +48,70 @@ extern "C" {
 }
 
 MainWindow::MainWindow(QWidget *parent) :
-       QMainWindow(parent),
-       _ui(new Ui::MainWindow)
+       QMainWindow(parent)
 {
-       _ui->setupUi(this);
+       setup_ui();
+}
+
+void MainWindow::setup_ui()
+{
+       setObjectName(QString::fromUtf8("MainWindow"));
+
+       resize(1024, 768);
+
+       // Set the window icon
+       QIcon icon;
+       icon.addFile(QString::fromUtf8(":/icons/sigrok-logo-notext.png"),
+               QSize(), QIcon::Normal, QIcon::Off);
+       setWindowIcon(icon);
+
+       // Setup the UI actions
+       _action_about = new QAction(this);
+       _action_about->setObjectName(QString::fromUtf8("actionAbout"));
+       _action_open = new QAction(this);
+       _action_open->setObjectName(QString::fromUtf8("actionOpen"));
+
+       // Setup the menu bar
+       _menu_bar = new QMenuBar(this);
+       _menu_bar->setGeometry(QRect(0, 0, 400, 25));
+
+       _menu_file = new QMenu(_menu_bar);
+       _menu_file->addAction(_action_open);
 
+       _menu_help = new QMenu(_menu_bar);
+       _menu_help->addAction(_action_about);
+
+       _menu_bar->addAction(_menu_file->menuAction());
+       _menu_bar->addAction(_menu_help->menuAction());
+
+       setMenuBar(_menu_bar);
+       QMetaObject::connectSlotsByName(this);
+
+       // Setup the toolbars
        _sampling_bar = new SamplingBar(this);
        connect(_sampling_bar, SIGNAL(run_stop()), this,
                SLOT(run_stop()));
        addToolBar(_sampling_bar);
 
-       _view = new SigView(_session, this);
-       _ui->verticalLayout->addWidget(_view);
-}
+       // Setup the central widget
+       _central_widget = new QWidget(this);
+       _vertical_layout = new QVBoxLayout(_central_widget);
+       _vertical_layout->setSpacing(6);
+       _vertical_layout->setContentsMargins(0, 0, 0, 0);
+       setCentralWidget(_central_widget);
 
-MainWindow::~MainWindow()
-{
-       delete _ui;
+       // Setup the status bar
+       _status_bar = new QStatusBar(this);
+       setStatusBar(_status_bar);
+
+       setWindowTitle(QApplication::translate("MainWindow", "sigrok-qt2", 0, QApplication::UnicodeUTF8));
+       _action_open->setText(QApplication::translate("MainWindow", "&Open...", 0, QApplication::UnicodeUTF8));
+       _action_about->setText(QApplication::translate("MainWindow", "&About...", 0, QApplication::UnicodeUTF8));
+       _menu_file->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8));
+       _menu_help->setTitle(QApplication::translate("MainWindow", "&Help", 0, QApplication::UnicodeUTF8));
+
+       _view = new SigView(_session, this);
+       _vertical_layout->addWidget(_view);
 }
 
 void MainWindow::on_actionOpen_triggered()
index da103c16ccd6fb4d13dbe5af5e18d13085c5195f..9605ccfbc832722daad20a69bfed278c0701ccce 100644 (file)
@@ -32,22 +32,42 @@ namespace Ui {
 class MainWindow;
 }
 
+class QAction;
+class QMenuBar;
+class QMenu;
+class QVBoxLayout;
+class QStatusBar;
+class QWidget;
+
 class MainWindow : public QMainWindow
 {
        Q_OBJECT
 
 public:
        explicit MainWindow(QWidget *parent = 0);
-       ~MainWindow();
 
 private:
-       Ui::MainWindow *_ui;
+       void setup_ui();
+
+private:
 
-       SamplingBar *_sampling_bar;
 
        SigSession _session;
        SigView *_view;
 
+       QAction *_action_open;
+       QAction *_action_about;
+
+       QMenuBar *_menu_bar;
+       QMenu *_menu_file;
+       QMenu *_menu_help;
+
+       QWidget *_central_widget;
+       QVBoxLayout *_vertical_layout;
+
+       SamplingBar *_sampling_bar;
+       QStatusBar *_status_bar;
+
 private slots:
 
        void on_actionOpen_triggered();
diff --git a/mainwindow.ui b/mainwindow.ui
deleted file mode 100644 (file)
index 1e17f11..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>1024</width>
-    <height>768</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>sigrok-qt2</string>
-  </property>
-  <property name="windowIcon">
-   <iconset>
-    <normaloff>:/icons/sigrok-logo-notext.png</normaloff>:/icons/sigrok-logo-notext.png</iconset>
-  </property>
-  <widget class="QMenuBar" name="menuBar">
-   <property name="geometry">
-    <rect>
-     <x>0</x>
-     <y>0</y>
-     <width>400</width>
-     <height>25</height>
-    </rect>
-   </property>
-   <widget class="QMenu" name="menu_Help">
-    <property name="title">
-     <string>&amp;Help</string>
-    </property>
-    <addaction name="actionAbout"/>
-   </widget>
-   <widget class="QMenu" name="menu_File">
-    <property name="title">
-     <string>&amp;File</string>
-    </property>
-    <addaction name="actionOpen"/>
-   </widget>
-   <addaction name="menu_File"/>
-   <addaction name="menu_Help"/>
-  </widget>
-  <widget class="QWidget" name="centralWidget">
-   <layout class="QVBoxLayout" name="verticalLayout">
-    <property name="margin">
-     <number>0</number>
-    </property>
-   </layout>
-  </widget>
-  <widget class="QStatusBar" name="statusBar" />
-  <action name="actionAbout">
-   <property name="text">
-    <string>&amp;About...</string>
-   </property>
-  </action>
-  <action name="actionOpen">
-   <property name="text">
-    <string>&amp;Open...</string>
-   </property>
-  </action>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>