annotate src/mainwindow.cpp @ 91:bbc3772fe877

Update translations
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 19 Jun 2015 14:28:11 +0200
parents c3000fa6ca56
children faece2c21229
rev   line source
25
64a51a42c01f Assign copyright correctly
Andre Heinecke <andre.heinecke@intevation.de>
parents: 16
diff changeset
1 /* Copyright (C) 2015 by ETH Zürich
64a51a42c01f Assign copyright correctly
Andre Heinecke <andre.heinecke@intevation.de>
parents: 16
diff changeset
2 * Software engineering by Intevation GmbH
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 *
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 * See LICENSE.txt for details.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7 */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 /** @file See mainwindow.h */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 #include "mainwindow.h"
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 #include "constants.h"
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
13 #include "metadataview.h"
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
14 #include "pngplayer.h"
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
15 #include "folderselectdialog.h"
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17 #include <QDebug>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 #include <QDialog>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
19 #include <QWidget>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20 #include <QHBoxLayout>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 #include <QLabel>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 #include <QPushButton>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 #include <QDir>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 #include <QFileDialog>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 #include <QMessageBox>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26 #include <QApplication>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 #include <QDragEnterEvent>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 #include <QDragLeaveEvent>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29 #include <QDropEvent>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30 #include <QDragMoveEvent>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31 #include <QMimeData>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 #include <QStandardPaths>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 #include <QStyle>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34 #include <QStatusBar>
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
35 #include <QTabWidget>
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
36 #include <QVBoxLayout>
32
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
37 #include <QShortcut>
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
38 #include <QKeySequence>
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
40 MainWindow::MainWindow() :
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
41 mDataView(NULL) {
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
42 setStatusBar(new QStatusBar());
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
43
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44 setupGUI();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
45 readSettings();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
46 setAcceptDrops(true);
32
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
47 setupShortcuts();
50
07744e276579 Add icon also for non Windows systems
Andre Heinecke <andre.heinecke@intevation.de>
parents: 44
diff changeset
48 #ifndef Q_OS_WIN
07744e276579 Add icon also for non Windows systems
Andre Heinecke <andre.heinecke@intevation.de>
parents: 44
diff changeset
49 QIcon windowIcon = QIcon(":/icon-64.png");
07744e276579 Add icon also for non Windows systems
Andre Heinecke <andre.heinecke@intevation.de>
parents: 44
diff changeset
50 setWindowIcon(windowIcon);
07744e276579 Add icon also for non Windows systems
Andre Heinecke <andre.heinecke@intevation.de>
parents: 44
diff changeset
51 #endif
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
52 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
53
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
54 void MainWindow::setupGUI() {
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
55 QTabWidget *tabWidget = new QTabWidget;
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
56 mDataView = new MetaDataView(this);
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
57 mPlayer = new PNGPlayer(this);
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
58
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
59 tabWidget->addTab(mPlayer, tr("Player"));
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
60 tabWidget->addTab(mDataView, tr("Filter/Details"));
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
61 tabWidget->setMovable(true);
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
62
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
63 setCentralWidget(tabWidget);
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
64
83
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
65 QPushButton *backBtn = new QPushButton;
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
66 backBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowBack));
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
67 backBtn->setToolTip(tr("Back to exam selection."));
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
68 tabWidget->setCornerWidget(backBtn, Qt::TopLeftCorner);
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
69
87
3b3a1384eb5f Show Version number in status bar
Andre Heinecke <andre.heinecke@intevation.de>
parents: 83
diff changeset
70 QLabel *versionLabel = new QLabel("<small>" + tr("Version: %1").arg(VERSION) + "</small>");
3b3a1384eb5f Show Version number in status bar
Andre Heinecke <andre.heinecke@intevation.de>
parents: 83
diff changeset
71 statusBar()->insertPermanentWidget(0, versionLabel);
3b3a1384eb5f Show Version number in status bar
Andre Heinecke <andre.heinecke@intevation.de>
parents: 83
diff changeset
72
83
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
73 connect (backBtn, &QPushButton::clicked, this, &MainWindow::goBack);
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
74 connect (mPlayer, &PNGPlayer::error, this, &MainWindow::showErrorMessage);
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
75 connect (mPlayer, &PNGPlayer::advance, mDataView, &MetaDataView::selectNextRow);
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
76 connect (mPlayer, &PNGPlayer::back, mDataView, &MetaDataView::selectPrevRow);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
77 connect (mPlayer, &PNGPlayer::jumpToFrame, mDataView, &MetaDataView::selectRow);
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
78 connect (mDataView, &MetaDataView::selectionChanged, mPlayer,
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
79 &PNGPlayer::showPicture);
5
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
80 connect (mDataView, &MetaDataView::selectionChanged, this,
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
81 &MainWindow::showPictureNameStatus);
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
82 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
83
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
84 void MainWindow::showErrorMessage(const QString& errMsg) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
85 QMessageBox::warning(this, tr("Error!"), errMsg);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
86 statusBar()->showMessage(errMsg);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
87 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
88
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
89 void MainWindow::closeEvent(QCloseEvent *event) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
90 mSettings.setValue("geometry", saveGeometry());
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
91 mSettings.setValue("windowState", saveState());
38
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 34
diff changeset
92 mPlayer->close();
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
93 QMainWindow::closeEvent(event);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
94 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
95
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
96 void MainWindow::readSettings() {
33
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
97 if (mSettings.contains("geometry")) {
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
98 restoreGeometry(mSettings.value("geometry").toByteArray());
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
99 restoreState(mSettings.value("windowState").toByteArray());
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
100 }
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
101 }
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
102 /*
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
103 void MainWindow::dragEnterEvent(QDragEnterEvent *event)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
104 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
105 if (event->mimeData()->hasUrls()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
106 foreach (const QUrl & url, event->mimeData()->urls()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
107 if (url.isLocalFile()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
108 event->acceptProposedAction();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
109 return;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
110 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
111 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
112 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
113 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
114
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
115 void MainWindow::dragMoveEvent(QDragMoveEvent *event)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
116 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
117 if (event->mimeData()->hasUrls()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
118 foreach (const QUrl & url, event->mimeData()->urls()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
119 if (url.isLocalFile()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
120 event->acceptProposedAction();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
121 return;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
122 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
123 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
124 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
125 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
126
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
127 void MainWindow::dropEvent(QDropEvent *event)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
128 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
129 const QMimeData *mimeData = event->mimeData();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
130
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
131 if (mimeData->hasUrls()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
132 foreach (const QUrl & url, mimeData->urls()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
133 if (!url.isLocalFile()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
134 qDebug() << "Ignoring drop of " << url;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
135 continue;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
136 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
137 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
138 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
139 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
140
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
141 void MainWindow::dragLeaveEvent(QDragLeaveEvent *event)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
142 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
143 event->accept();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
144 }
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
145 */
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
146 void MainWindow::setFolder(const QString& folder)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
147 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
148 QFileInfo fi(folder);
16
6d5dd3ae2ad3 Save last selection in settings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 9
diff changeset
149 mSettings.setValue(SUB_FOLDER_KEY, folder);
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
150 if (!fi.isDir() || !fi.isReadable()) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
151 showErrorMessage(tr("Failed to access directory: '%1'").arg(folder));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
152 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
153 QDir dir = QDir(folder);
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
154 QFileInfo metaData = dir.absoluteFilePath("metadata.csv");
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
155 if (!metaData.exists() || !metaData.isReadable()) {
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
156 showErrorMessage(tr("Failed to access meta data file: '%1'").arg(
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
157 metaData.filePath()));
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
158
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
159 }
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
160 QString errorMsg = mDataView->parseMetaData(metaData.filePath());
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
161 if (!errorMsg.isEmpty()) {
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
162 showErrorMessage(errorMsg);
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
163 }
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
164 statusBar()->showMessage(tr("Parsed: '%1'").arg(metaData.filePath()));
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
165 qDebug() << "Parsed: " << metaData.filePath();
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
166 mCurFolder = folder;
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
167 mPlayer->setBaseDir(folder);
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
168 mDataView->selectNextRow();
33
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
169 if (!mSettings.contains("geometry")) {
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
170 qDebug() << "Showing maximized";
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
171 show();
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
172 showMaximized();
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
173 } else {
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
174 show();
58f1b3c330af (issue9) Show maximized by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 32
diff changeset
175 }
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
176 }
5
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
177
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
178 void MainWindow::showPictureNameStatus(const QString& fileName, int current,
44
73e6b6b12412 (issue 1,2) Make the column used for the Timestamp value configurable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 42
diff changeset
179 int max, const QString& timestamp) {
5
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
180 if (current != 0 && max != 0) {
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
181 statusBar()->showMessage(tr("Showing: '%1'").arg(fileName));
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
182 }
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
183 }
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
184
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
185 void MainWindow::setRootFolder(const QString &folder) {
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
186 mRootFolder = folder;
16
6d5dd3ae2ad3 Save last selection in settings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 9
diff changeset
187 QDir dir(folder);
6d5dd3ae2ad3 Save last selection in settings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 9
diff changeset
188 dir.cdUp();
6d5dd3ae2ad3 Save last selection in settings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 9
diff changeset
189 mSettings.setValue(ROOT_FOLDER_KEY, dir.absolutePath());
6d5dd3ae2ad3 Save last selection in settings
Andre Heinecke <andre.heinecke@intevation.de>
parents: 9
diff changeset
190
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
191 showSubFolderSelect();
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
192 }
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
193
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
194 void MainWindow::showSubFolderSelect() {
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
195 const QString subPattern = mSettings.value(SUB_FOLDER_PATTERN_KEY,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
196 SUB_FOLDER_PATTERN).toString();
42
2836b6ed430a Write out the Folder patterns even if they are unchanged
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
197 mSettings.setValue(SUB_FOLDER_PATTERN_KEY, subPattern);
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
198 FolderSelectDialog *fsDialog = new FolderSelectDialog(mRootFolder,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
199 subPattern);
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
200 fsDialog->setWindowTitle(tr("Persons"));
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
201 connect(fsDialog, &FolderSelectDialog::folderSelected,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
202 this, &MainWindow::setFolder);
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
203
90
c3000fa6ca56 Add back button to subfolder selection dialog
Andre Heinecke <andre.heinecke@intevation.de>
parents: 87
diff changeset
204 connect(fsDialog, &FolderSelectDialog::backClicked,
c3000fa6ca56 Add back button to subfolder selection dialog
Andre Heinecke <andre.heinecke@intevation.de>
parents: 87
diff changeset
205 this, &MainWindow::showWithFolderSelect);
c3000fa6ca56 Add back button to subfolder selection dialog
Andre Heinecke <andre.heinecke@intevation.de>
parents: 87
diff changeset
206 connect(fsDialog, &FolderSelectDialog::backClicked,
c3000fa6ca56 Add back button to subfolder selection dialog
Andre Heinecke <andre.heinecke@intevation.de>
parents: 87
diff changeset
207 fsDialog, &QDialog::close);
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
208 fsDialog->show();
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
209 // connect(fsDialog, &QDialog::closeEvent, fsDialog, &QObject::deleteLater);
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
210 }
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
211
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
212 void MainWindow::showWithFolderSelect() {
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
213 const QString startFolder = mSettings.value(ROOT_FOLDER_KEY,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
214 QString()).toString();
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
215 const QString rootPattern = mSettings.value(ROOT_FOLDER_PATTERN_KEY,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
216 DEFAULT_ROOT_PATTERN).toString();
42
2836b6ed430a Write out the Folder patterns even if they are unchanged
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
217 mSettings.setValue(ROOT_FOLDER_PATTERN_KEY, rootPattern);
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
218 FolderSelectDialog *fsDialog = new FolderSelectDialog(startFolder,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
219 rootPattern,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
220 tr("Root-Path"));
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
221 fsDialog->setWindowTitle(tr("Exams"));
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
222 connect(fsDialog, &FolderSelectDialog::folderSelected,
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
223 this, &MainWindow::setRootFolder);
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
224
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
225 fsDialog->show();
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
226 // connect(fsDialog, &QDialog::closeEvent, fsDialog, &QObject::deleteLater);
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 5
diff changeset
227 }
32
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
228
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
229 void MainWindow::setupShortcuts() {
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
230 QShortcut *next = new QShortcut(Qt::Key_Right, this);
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
231 QShortcut *prev = new QShortcut(Qt::Key_Left, this);
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
232 QShortcut *pause = new QShortcut(Qt::Key_Space, this);
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
233
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
234 connect(pause, &QShortcut::activated, mPlayer, &PNGPlayer::togglePlay);
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
235 connect(next, &QShortcut::activated, mDataView, &MetaDataView::selectNextRow);
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
236 connect(prev, &QShortcut::activated, mDataView, &MetaDataView::selectPrevRow);
179239c94740 (issue7-8) Add shortcuts for play/pause and next
Andre Heinecke <andre.heinecke@intevation.de>
parents: 25
diff changeset
237 }
83
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
238
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
239 void MainWindow::goBack() {
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
240 hide();
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
241 showWithFolderSelect();
11aaa9214cfb Add back to folder selection button
Andre Heinecke <andre.heinecke@intevation.de>
parents: 56
diff changeset
242 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)