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 "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")));
}

View 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;
}; };

View File

@@ -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>
<pixmapfunction/> <widget class="QMenuBar" name="menubar">
<connections/> <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> </ui>