hydrogen 1.2.6
FilesystemInfoForm.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#include <QDesktopServices>
24
25#include "FilesystemInfoForm.h"
26#include "ui_FilesystemInfoForm_UI.h"
27#include "Skin.h"
28
31
33 QWidget( parent ),
36{
37 ui->setupUi(this);
38
39 QColor windowColor = H2Core::Preferences::get_instance()->getColorTheme()->m_windowColor;
40 QColor windowTextColor = H2Core::Preferences::get_instance()->getColorTheme()->m_windowTextColor;
41
42 ui->tmpDirWarningButton->setIcon( QIcon( Skin::getSvgImagePath() + "/icons/warning.svg" ) );
43 ui->tmpDirWarningButton->setToolTip( tr( "Filesystem is not writable!" ) );
44 ui->tmpDirWarningButton->setType( Button::Type::Icon );
45 ui->tmpDirWarningButton->setSize( QSize( 16, 14 ) );
46
47 ui->tmpDirLineEdit->setReadOnly( true );
48
49 ui->usrDataDirWarningButton->setIcon( QIcon( Skin::getSvgImagePath() + "/icons/warning.svg" ) );
50 ui->usrDataDirWarningButton->setToolTip( tr( "User data folder is not writable!" ) );
51 ui->usrDataDirWarningButton->setType( Button::Type::Icon );
52 ui->usrDataDirWarningButton->setSize( QSize( 16, 14 ) );
53
54 ui->usrDataDirLineEdit->setReadOnly( true );
55 ui->sysDataDirLineEdit->setReadOnly( true );
56
57 updateInfo();
58}
59
64
66{
67 updateInfo();
68}
70{
71 const QString tmpDir = H2Core::Filesystem::tmp_dir();
72 const QString usrDataDir = H2Core::Filesystem::usr_data_path();
73 const QString sysDataDir = H2Core::Filesystem::sys_data_path();
74
75 ui->tmpDirLineEdit->setText( tmpDir);
76 ui->tmpDirLineEdit->setToolTip( tmpDir );
77
78 if(!H2Core::Filesystem::dir_writable( tmpDir, true)) {
79 ui->tmpDirWarningButton->show();
80 } else {
81 ui->tmpDirWarningButton->hide();
82 }
83
84 ui->usrDataDirLineEdit->setText( usrDataDir );
85 ui->usrDataDirLineEdit->setToolTip( usrDataDir );
86
87 if(!H2Core::Filesystem::dir_writable( usrDataDir, true)) {
88 ui->usrDataDirWarningButton->show();
89 } else {
90 ui->usrDataDirWarningButton->hide();
91 }
92
93 ui->sysDataDirLineEdit->setText( sysDataDir );
94 ui->sysDataDirLineEdit->setToolTip( sysDataDir );
95
96 //System data dir is not writable for the user, so no warning here...
97}
98
99void
101{
102 QDesktopServices::openUrl( QUrl::fromLocalFile( H2Core::Filesystem::tmp_dir() ) );
103}
104
105void
107{
108 QDesktopServices::openUrl( QUrl::fromLocalFile( H2Core::Filesystem::usr_data_path() ) );
109}
110
111void
113{
114 QDesktopServices::openUrl( QUrl::fromLocalFile( H2Core::Filesystem::sys_data_path() ) );
115}
@ Icon
Button is both flat and has a transparent background.
Definition Button.h:75
virtual void showEvent(QShowEvent *) override
Ui::FilesystemInfoForm * ui
FilesystemInfoForm(QWidget *parent=nullptr)
static QString sys_data_path()
returns system data path
static bool dir_writable(const QString &path, bool silent=false)
returns true if the given path is a writable regular directory
static QString tmp_dir()
returns temp path
static QString usr_data_path()
returns user data path
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
const std::shared_ptr< ColorTheme > getColorTheme() const
static QString getSvgImagePath()
Definition Skin.h:40