mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 03:27:40 +01:00
debug: Generalize debug feature check
Move the debug console variable check to a static method in the Application class and use environment variable CLEMENTINE_DEBUG instead of CLEMENTINE_DEBUG_CONSOLE. This will allow debug features to be enabled elsewhere in the code. Example: CLEMENTINE_DEBUG=1 clementine
This commit is contained in:
parent
79ca9147e9
commit
7ba322b10b
@ -69,9 +69,17 @@ bool Application::kIsPortable = false;
|
||||
const char* Application::kLegacyPortableDataDir = "data";
|
||||
const char* Application::kDefaultPortableDataDir = "clementine-data";
|
||||
const char* Application::kPortableDataDir = nullptr;
|
||||
const char* Application::kDebugFeaturesKey = "CLEMENTINE_DEBUG";
|
||||
const QStringList Application::kDefaultMusicExtensionsAllowedRemotely = {
|
||||
"aac", "alac", "flac", "m3u", "m4a", "mp3", "ogg", "wav", "wmv"};
|
||||
|
||||
// Use CLEMENTINE_DEBUG=1 to enable debug features.
|
||||
bool Application::DebugFeaturesEnabled() {
|
||||
QString showConsole =
|
||||
QProcessEnvironment::systemEnvironment().value(kDebugFeaturesKey, "0");
|
||||
return (showConsole == "1");
|
||||
}
|
||||
|
||||
class ApplicationImpl {
|
||||
public:
|
||||
ApplicationImpl(Application* app)
|
||||
|
@ -67,7 +67,9 @@ class Application : public QObject {
|
||||
static const char* kLegacyPortableDataDir;
|
||||
static const char* kDefaultPortableDataDir;
|
||||
static const QStringList kDefaultMusicExtensionsAllowedRemotely;
|
||||
static const char* kDebugFeaturesKey;
|
||||
static bool IsPortable() { return kIsPortable; }
|
||||
static bool DebugFeaturesEnabled();
|
||||
|
||||
explicit Application(QObject* parent = nullptr);
|
||||
~Application();
|
||||
|
@ -154,7 +154,6 @@ void qt_mac_set_dock_menu(QMenu*);
|
||||
|
||||
const char* MainWindow::kSettingsGroup = "MainWindow";
|
||||
const char* MainWindow::kAllFilesFilterSpec = QT_TR_NOOP("All Files (*)");
|
||||
const char* MainWindow::kShowDebugConsoleKey = "CLEMENTINE_DEBUG_CONSOLE";
|
||||
|
||||
namespace {
|
||||
const int kTrackSliderUpdateTimeMs = 500;
|
||||
@ -942,9 +941,7 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
||||
SLOT(EnableKittens(bool)));
|
||||
connect(ui_->action_kittens, SIGNAL(toggled(bool)), app_->network_remote(),
|
||||
SLOT(EnableKittens(bool)));
|
||||
QString showConsole =
|
||||
QProcessEnvironment::systemEnvironment().value(kShowDebugConsoleKey, "0");
|
||||
if (showConsole == "1")
|
||||
if (app->DebugFeaturesEnabled())
|
||||
connect(ui_->action_console, SIGNAL(triggered()), SLOT(ShowConsole()));
|
||||
else
|
||||
ui_->action_console->setVisible(false);
|
||||
|
@ -98,7 +98,6 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
static const char* kSettingsGroup;
|
||||
static const char* kAllFilesFilterSpec;
|
||||
static const char* kShowDebugConsoleKey;
|
||||
|
||||
// Don't change the values
|
||||
enum StartupBehaviour {
|
||||
|
Loading…
x
Reference in New Issue
Block a user