Refactor simple dialogs to use Lazy
This commit is contained in:
parent
74e6a1744f
commit
b99b090adc
|
@ -29,6 +29,9 @@ class Lazy {
|
|||
public:
|
||||
explicit Lazy(std::function<T*()> init) : init_(init) {}
|
||||
|
||||
// Convenience constructor that will lazily default construct the object.
|
||||
Lazy() : init_([]() { return new T; }) {}
|
||||
|
||||
T* get() const {
|
||||
CheckInitialised();
|
||||
return ptr_.get();
|
||||
|
|
|
@ -2196,10 +2196,6 @@ void MainWindow::PlaylistUndoRedoChanged(QAction* undo, QAction* redo) {
|
|||
}
|
||||
|
||||
void MainWindow::AddFilesToTranscoder() {
|
||||
if (!transcode_dialog_) {
|
||||
transcode_dialog_.reset(new TranscodeDialog);
|
||||
}
|
||||
|
||||
QStringList filenames;
|
||||
|
||||
for (const QModelIndex& index :
|
||||
|
@ -2475,24 +2471,14 @@ EditTagDialog* MainWindow::CreateEditTagDialog() {
|
|||
}
|
||||
|
||||
void MainWindow::ShowAboutDialog() {
|
||||
if (!about_dialog_) {
|
||||
about_dialog_.reset(new About);
|
||||
}
|
||||
|
||||
about_dialog_->show();
|
||||
}
|
||||
|
||||
void MainWindow::ShowTranscodeDialog() {
|
||||
if (!transcode_dialog_) {
|
||||
transcode_dialog_.reset(new TranscodeDialog);
|
||||
}
|
||||
transcode_dialog_->show();
|
||||
}
|
||||
|
||||
void MainWindow::ShowErrorDialog(const QString& message) {
|
||||
if (!error_dialog_) {
|
||||
error_dialog_.reset(new ErrorDialog);
|
||||
}
|
||||
error_dialog_->ShowMessage(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ signals:
|
|||
SystemTrayIcon* tray_icon_;
|
||||
OSD* osd_;
|
||||
Lazy<EditTagDialog> edit_tag_dialog_;
|
||||
std::unique_ptr<About> about_dialog_;
|
||||
Lazy<About> about_dialog_;
|
||||
|
||||
GlobalShortcuts* global_shortcuts_;
|
||||
|
||||
|
@ -318,8 +318,8 @@ signals:
|
|||
std::unique_ptr<AddStreamDialog> add_stream_dialog_;
|
||||
std::unique_ptr<AlbumCoverManager> cover_manager_;
|
||||
std::unique_ptr<Equalizer> equalizer_;
|
||||
std::unique_ptr<TranscodeDialog> transcode_dialog_;
|
||||
std::unique_ptr<ErrorDialog> error_dialog_;
|
||||
Lazy<TranscodeDialog> transcode_dialog_;
|
||||
Lazy<ErrorDialog> error_dialog_;
|
||||
Lazy<OrganiseDialog> organise_dialog_;
|
||||
std::unique_ptr<QueueManager> queue_manager_;
|
||||
|
||||
|
|
Loading…
Reference in New Issue