aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm/MainUI.h
blob: ccc85f72528531e6878ffb0265c27a0be04b1f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//===========================================
//  Lumina-DE source code
//  Copyright (c) 2014, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
//  This is the main interface for the Lumina File Manager (Insight)
//===========================================
#ifndef _LUMINA_FILE_MANAGER_UI_H
#define _LUMINA_FILE_MANAGER_UI_H
// Qt includes
#include <QMainWindow>
#include <QTabBar>
#include <QLineEdit>
#include <QFileSystemModel>
#include <QStringList>
#include <QDebug>
#include <QAction>
#include <QProcess>
#include <QSettings>
#include <QInputDialog>
#include <QMessageBox>
#include <QDir>
#include <QTimer>
#include <QDateTime>
#include <QShortcut>
#include <QCompleter>
#include <QClipboard>
#include <QMimeData>
#include <QTreeWidgetItem>
#include <QListWidgetItem>
#include <QRadioButton>
#include <QWidgetAction>
#include <QImageReader>
#include <QScrollBar>
#include <QFileDialog>
#include <QResizeEvent>
#include <QDesktopWidget>
#include <QThread>
#include <QUrl>
#include <QThread>

//Multimedia Widgets
#include <QVideoWidget>
#include <QMediaPlayer>

// libLumina includes
#include <LuminaXDG.h>
#include <LuminaOS.h>

// Local includes
#include "FODialog.h" //file operation dialog
#include "BMMDialog.h" //bookmark manager dialog
#include "MimeIconProvider.h" //icon provider for the view widgets
#include "BackgroundWorker.h"

namespace Ui{
	class MainUI;
};

class MainUI : public QMainWindow{
	Q_OBJECT
public:
	MainUI();
	~MainUI();

	void OpenDirs(QStringList); //called from the main.cpp after initialization

public slots:
	void setupIcons(); 			//used during initialization

private:
	Ui::MainUI *ui;
	QThread *workThread;
	BackgroundWorker *worker;
	//Internal non-ui widgets
	QTabBar *tabBar;
	QLineEdit *currentDir;
	QFileSystemModel *fsmod, *snapmod;
	//QFileSystemWatcher *fswatcher;
	MimeIconProvider *iconProv;
	QMenu *contextMenu;
	QRadioButton *radio_view_details, *radio_view_list, *radio_view_icons;
	QWidgetAction *detWA, *listWA, *icoWA;
	QString favdir;

	//Phonon Widgets for the multimedia player
	QMediaPlayer *mediaObj;
	QVideoWidget *videoDisplay;
	//Phonon::AudioOutput *audioOut;
	QSlider *playerSlider;
	QString playerTTime; //total time - to prevent recalculation every tick

	//Internal variables
	QStringList snapDirs; //internal saved variable for the discovered zfs snapshot dirs
	QString CItem; //the item that was right-clicked (for the context menu)
	//QStringList imgFilter, multiFilter; //image/multimedia filters
	QSettings *settings;
	QShortcut *nextTabLShort, *nextTabRShort, *closeTabShort, *copyFilesShort, *pasteFilesShort, *deleteFilesShort;
	QCompleter *dirCompleter;
	bool isUserWritable, keepFocus;
	QTimer *syncTimer;

	//Simplification Functions
	void setupConnections(); 	//used during initialization
	void loadSettings(); 		//used during initialization
	
	void RebuildBookmarksMenu();
	void RebuildDeviceMenu();
	
	bool checkUserPerms();
	QString msToText(qint64 ms);
	
	//Common functions for browser info/usage
	QString getCurrentDir();
	void setCurrentDir(QString);
	QFileInfoList getSelectedItems();

private slots:
	void slotSingleInstance(QStringList in){
	  this->show();
	  this->raise();
	  this->OpenDirs(in);
	}
	
	void slotStartSyncTimer();
	
	//General button check functions (started in a seperate thread!)
	void AvailableMultimediaFiles(QStringList files);
	void AvailableBackups(QString basedir, QStringList snapdirs);
	void AvailablePictures(QStringList files);
	
	//General page switching
	void goToMultimediaPage();
	void goToRestorePage();
	void goToSlideshowPage();
	void goToBrowserPage();
	
	//Menu Actions
	void on_actionNew_Tab_triggered();
	void on_actionClose_triggered();
	void on_actionView_Hidden_Files_triggered();
	void on_actionShow_Action_Buttons_triggered();
	void goToBookmark(QAction*);
	void goToDevice(QAction*);
	void viewModeChanged(bool);
	
	//Toolbar Actions
	void on_actionBack_triggered();
	void on_actionUpDir_triggered();
	void on_actionHome_triggered();
	void on_actionBookMark_triggered();

	//Browser Functions
	void startEditDir(QWidget *old, QWidget *now);
	void goToDirectory(); //go to a manually typed in directory
	void reloadDirectory(); //Update the widget with the dir contents
	void currentDirectoryLoaded(); //The file system model re-loaded the directory
	void on_tool_addToDir_clicked();
	void tabChanged(int tab);
	void tabClosed(int tab = -1);
	void prevTab();
	void nextTab();
	void ItemRun( const QModelIndex&);
	//void ItemRun(QTreeWidgetItem *item);
	//void ItemRun(QListWidgetItem *item);
	void OpenContextMenu(const QPoint&);
	void ItemSelectionChanged();

	//Slideshow Functions
	void showNewPicture();
	void firstPicture();
	void prevPicture();
	void nextPicture();
	void lastPicture();
	void removePicture();
	void rotatePictureLeft();
	void rotatePictureRight();
	
	//ZFS Restore Functions
	void snapshotLoaded();
	void showSnapshot();
	void nextSnapshot();
	void prevSnapshot();
	void restoreItems();
	
	//Multimedia Player Functions
	void playerStart();
	void playerError();
	void playerStop();
	void playerPause();
	void playerNext();
	void playerPrevious();
	void playerFinished(); //automatically called by the media object
	void playerStatusChanged(QMediaPlayer::MediaStatus stat); //automatically called
	void playerStateChanged(QMediaPlayer::State newstate); //automatically called by the media object
	void playerVideoAvailable(bool showVideo); //automatically called by the media object
	void playerDurationChanged(qint64);
	void playerTimeChanged(qint64 ctime); //automatically called by the media object
	void playerSliderMoved(int);
	void playerSliderHeld();
	void playerSliderChanged();
	void playerFileChanged();
	
	//Context Menu Actions
	 // - single item actions
	void OpenItem(); //run "lumina-open" on it
	void OpenItemWith(); //run "lumina-open -select" on it
	void OpenDir(); //open the dir in a new tab
	void RemoveItem(); //Remove the item permanently
	void RenameItem();
	void FavoriteItem();
	 // - full selection actions
	void CutItems();
	void CopyItems();
	void PasteItems();

signals:
	void DirChanged(QString path);

protected:
	void resizeEvent(QResizeEvent*);

};

#endif
bgstack15