raDIYo 0.4
swsetupcontrol.cpp
1/***************************************************************************
2
3 source::worx raDIYo
4 Copyright © 2020-2022 c.holzheuer
5 c.holzheuer@sourceworx.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***************************************************************************/
13
14
15#include <QDebug>
16#include <QFileDialog>
17#include <QInputDialog>
18
19#include <swsetupcontrol.h>
20#include <swradiyomainwidget.h>
21
22
23SWSetupControl::SWSetupControl( SWRaDIYoMainWidget* parent )
24 : SWAbstractControl( parent )
25{
26
27 setupUi( this );
28 QString defaultDir = _controller->settings().value( raDIYo::KeySongsDir ).toString();
29 _songsDir->setText( defaultDir );
30 connect( _buttonSongs, SIGNAL( clicked() ), this, SLOT( onSongsClicked() ) );
31 connect( _buttonSender, SIGNAL( clicked() ), this, SLOT( onSenderClicked() ) );
32}
33
34
35
36SWSetupControl::~SWSetupControl()
37{
38
39}
40
41void SWSetupControl::onSongsClicked()
42{
43 /*
44 * QList<QUrl> urls;
45 urls << QUrl::fromLocalFile("/Users/foo/Code/qt5")
46 << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).first());
47
48 QFileDialog dialog;
49 dialog.setSidebarUrls(urls);
50 dialog.setFileMode(QFileDialog::AnyFile);
51 if(dialog.exec()) {
52 // ...
53 }*/
54
55 QFileDialog dialog( this, "Songs Directory" );
56 //QFileDialog dialog( this, Qt::Widget | Qt::FramelessWindowHint );
57 dialog.setFileMode( QFileDialog::Directory );
58
59 QString dirName = _controller->settings().value( raDIYo::KeySongsDir ).toString();
60 QDir defaultDir( dirName );
61 if( !defaultDir.exists() )
62 dirName = QDir::homePath();
63 dialog.setDirectory( dirName );
64 //dialog.setWindowFlags( Qt::Widget|Qt::FramelessWindowHint );
65 if( dialog.exec() )
66 {
67 QStringList files = dialog.selectedFiles();
68 if( !files.empty() )
69 {
70 _controller->settings().setValue( raDIYo::KeySongsDir, files[0] );
71 _songsDir->setText( files[0] );
72 }
73
74 }
75
76}
77
78
79void SWSetupControl::onSenderClicked()
80{
81
82 bool ok;
83 QString senderList = _controller->settings().value( raDIYo::KeySenderList ).toString();
84 QString text = QInputDialog::getMultiLineText( this, tr("Senderlist"), "moo", senderList, &ok);
85}
86
87void SWSetupControl::onDialClicked()
88{
89 qDebug() << "setup control onClick";
90}
91
92void SWSetupControl::onDialValueChanged( int value )
93{
94 qDebug() << "setup control on ValueChanged: " << value;
95}