hydrogen 1.2.6
FileDialog.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY, without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include "FileDialog.h"
24#include "../CommonStrings.h"
25#include "../HydrogenApp.h"
26
27#include <core/config.h>
29
30FileDialog::FileDialog( QWidget *pParent )
31 : QFileDialog( pParent ) {
32
33#if not defined(WIN32) and not defined(__APPLE__) // Linux
34 // Occassionally users reported freezing of Hydrogen when interactive with
35 // native file dialogs on Linux, e.g. #2165. Qt's bug tracker is full of
36 // such tickets and it seems to be a problem with the interaction of the Qt
37 // library with the underlying windows manager. Since I
38 // (@theGreatWhiteShark) was never able to reproduce this issue and we have
39 // no control of which Qt version will be combined using with window
40 // manager, we will circumvent this issue by avoid all native file dialogs.
41 setOption( QFileDialog::DontUseNativeDialog, true );
42#endif
43}
44
47
49 auto pCommonStrings = HydrogenApp::get_instance()->getCommonStrings();
50
51 QFileInfo fileInfo( selectedFiles().first() );
52 if ( acceptMode() == QFileDialog::AcceptSave &&
54 fileInfo.absoluteDir().absolutePath(), false ) ) {
55 QMessageBox::warning( this, "Hydrogen",
56 pCommonStrings->getFileDialogMissingWritePermissions(),
57 QMessageBox::Ok );
58 return;
59 }
60
61 QFileDialog::accept();
62}
void accept()
FileDialog(QWidget *pParent)
static bool dir_writable(const QString &path, bool silent=false)
returns true if the given path is a writable regular directory
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
std::shared_ptr< CommonStrings > getCommonStrings()