All Classes Namespaces Functions Variables Enumerations Properties Pages
preferencesdialog.cpp
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 #include "preferencesdialog.h"
18 
19 #include "ui_preferencesdialog.h"
20 
21 PreferencesDialog::PreferencesDialog(QWidget* parent) :
22  QDialog(parent),
23  ui(new Ui::PreferencesDialog)
24 {
25  ui->setupUi(this);
26 }
27 
28 PreferencesDialog::~PreferencesDialog()
29 {
30  delete ui;
31 }
32 
33 void PreferencesDialog::init(PreferenceManager* m)
34 {
35  Q_ASSERT(m != nullptr);
36  mPrefManager = m;
37 
38  ui->general->setManager(mPrefManager);
39  ui->general->updateValues();
40 
41  ui->filesPage->setManager(mPrefManager);
42  ui->filesPage->updateValues();
43 
44  ui->timeline->setManager(mPrefManager);
45  ui->timeline->updateValues();
46 
47  ui->tools->setManager(mPrefManager);
48  ui->tools->updateValues();
49 
50  ui->shortcuts->setManager(mPrefManager);
51 
52  connect(ui->general, &GeneralPage::windowOpacityChange, this, &PreferencesDialog::windowOpacityChange);
53  connect(ui->timeline, &TimelinePage::soundScrubChanged, this, &PreferencesDialog::soundScrubChanged);
54  connect(ui->timeline, &TimelinePage::soundScrubMsecChanged, this, &PreferencesDialog::soundScrubMsecChanged);
55  connect(ui->filesPage, &FilesPage::clearRecentList, this, &PreferencesDialog::clearRecentList);
57 
58  auto onCurrentItemChanged = static_cast<void (QListWidget::*)(QListWidgetItem*, QListWidgetItem*)>(&QListWidget::currentItemChanged);
59  connect(ui->contentsWidget, onCurrentItemChanged, this, &PreferencesDialog::changePage);
60 }
61 
62 void PreferencesDialog::closeEvent(QCloseEvent*)
63 {
65 }
66 
67 void PreferencesDialog::changePage(QListWidgetItem* current, QListWidgetItem* previous)
68 {
69  if (!current)
70  current = previous;
71 
72  ui->pagesWidget->setCurrentIndex(ui->contentsWidget->row(current));
73 }
74 
75 void PreferencesDialog::updateRecentListBtn(bool isEmpty)
76 {
77  if (isEmpty)
78  {
79  emit updateRecentFileListBtn();
80  }
81 }
bool close()
void setupUi(QWidget *widget)
virtual void done(int r)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)