Added file open dialog

This commit is contained in:
0xFEEDC0DE64
2018-04-12 20:11:07 +02:00
parent 733d514436
commit a1ec681ee0
3 changed files with 74 additions and 10 deletions

View File

@@ -1,14 +1,26 @@
#include "sketchmainwindow.h"
#include "ui_sketchmainwindow.h"
#include <QFileDialog>
SketchMainWindow::SketchMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::SketchMainWindow)
{
ui->setupUi(this);
ui->actionOpen->setShortcut(QKeySequence::Open);
ui->actionQuit->setShortcut(QKeySequence::Quit);
connect(ui->actionOpen, &QAction::triggered, this, &SketchMainWindow::openPressed);
}
SketchMainWindow::~SketchMainWindow()
{
delete ui;
}
void SketchMainWindow::openPressed()
{
QFileDialog::getOpenFileName(this, tr("Select a sketch file"), QString(), QStringLiteral("%0 (*.sketch)").arg(tr("Sketch file")));
}

View File

@@ -15,6 +15,9 @@ public:
explicit SketchMainWindow(QWidget *parent = 0);
~SketchMainWindow();
private Q_SLOTS:
void openPressed();
private:
Ui::SketchMainWindow *ui;
};

View File

@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>SketchMainWindow</class>
<widget name="SketchMainWindow" class="QMainWindow">
<widget class="QMainWindow" name="SketchMainWindow">
<property name="geometry">
<rect>
<x>0</x>
@@ -13,12 +11,63 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>Sketch Viewer</string>
</property>
<widget name="menubar" class="QMenuBar"/>
<widget name="centralwidget" class="QWidget"/>
<widget name="statusbar" class="QStatusBar"/>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTabWidget" name="tabWidget"/>
</item>
</layout>
</widget>
<pixmapfunction/>
<connections/>
<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>&amp;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>&amp;Open</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>&amp;Quit</string>
</property>
</action>
</widget>
<resources/>
<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>