Added file open dialog
This commit is contained in:
@@ -1,14 +1,26 @@
|
|||||||
#include "sketchmainwindow.h"
|
#include "sketchmainwindow.h"
|
||||||
#include "ui_sketchmainwindow.h"
|
#include "ui_sketchmainwindow.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
SketchMainWindow::SketchMainWindow(QWidget *parent) :
|
SketchMainWindow::SketchMainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::SketchMainWindow)
|
ui(new Ui::SketchMainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->actionOpen->setShortcut(QKeySequence::Open);
|
||||||
|
ui->actionQuit->setShortcut(QKeySequence::Quit);
|
||||||
|
|
||||||
|
connect(ui->actionOpen, &QAction::triggered, this, &SketchMainWindow::openPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
SketchMainWindow::~SketchMainWindow()
|
SketchMainWindow::~SketchMainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SketchMainWindow::openPressed()
|
||||||
|
{
|
||||||
|
QFileDialog::getOpenFileName(this, tr("Select a sketch file"), QString(), QStringLiteral("%0 (*.sketch)").arg(tr("Sketch file")));
|
||||||
|
}
|
||||||
|
@@ -15,6 +15,9 @@ public:
|
|||||||
explicit SketchMainWindow(QWidget *parent = 0);
|
explicit SketchMainWindow(QWidget *parent = 0);
|
||||||
~SketchMainWindow();
|
~SketchMainWindow();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void openPressed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SketchMainWindow *ui;
|
Ui::SketchMainWindow *ui;
|
||||||
};
|
};
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<author/>
|
|
||||||
<comment/>
|
|
||||||
<exportmacro/>
|
|
||||||
<class>SketchMainWindow</class>
|
<class>SketchMainWindow</class>
|
||||||
<widget name="SketchMainWindow" class="QMainWindow">
|
<widget class="QMainWindow" name="SketchMainWindow">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@@ -13,12 +11,63 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>Sketch Viewer</string>
|
||||||
</property>
|
</property>
|
||||||
<widget name="menubar" class="QMenuBar"/>
|
<widget class="QWidget" name="centralwidget">
|
||||||
<widget name="centralwidget" class="QWidget"/>
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<widget name="statusbar" class="QStatusBar"/>
|
<item>
|
||||||
|
<widget class="QTabWidget" name="tabWidget"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>800</width>
|
||||||
|
<height>20</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuFile">
|
||||||
|
<property name="title">
|
||||||
|
<string>&File</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionOpen"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionQuit"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuFile"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<action name="actionOpen">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Open</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionQuit">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Quit</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<pixmapfunction/>
|
<resources/>
|
||||||
<connections/>
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>actionQuit</sender>
|
||||||
|
<signal>triggered()</signal>
|
||||||
|
<receiver>SketchMainWindow</receiver>
|
||||||
|
<slot>close()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>-1</x>
|
||||||
|
<y>-1</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>399</x>
|
||||||
|
<y>299</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
Reference in New Issue
Block a user