From: Joel Holdsworth Date: Sun, 8 Jul 2012 09:31:50 +0000 (+0100) Subject: Replaced mainwindow.ui XML with code X-Git-Tag: pulseview-0.1.0~322 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7d5425efcefd801264a504f8a9d92977f2be6eeb;p=pulseview.git Replaced mainwindow.ui XML with code --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e137145..5f99a4bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,6 @@ set(sigrok-qt2_HEADERS set(sigrok-qt2_FORMS about.ui - mainwindow.ui ) set(sigrok-qt2_RESOURCES diff --git a/mainwindow.cpp b/mainwindow.cpp index 3390e183..d827e2dc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,12 +22,18 @@ extern "C" { #include } +#include +#include +#include #include +#include +#include +#include +#include +#include #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() diff --git a/mainwindow.h b/mainwindow.h index da103c16..9605ccfb 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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 index 1e17f115..00000000 --- a/mainwindow.ui +++ /dev/null @@ -1,66 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 1024 - 768 - - - - sigrok-qt2 - - - - :/icons/sigrok-logo-notext.png:/icons/sigrok-logo-notext.png - - - - - 0 - 0 - 400 - 25 - - - - - &Help - - - - - - &File - - - - - - - - - - 0 - - - - - - - &About... - - - - - &Open... - - - - - - -