summaryrefslogtreecommitdiffstats
path: root/src/library/library.cpp
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2014-12-06 15:27:52 -0500
committerRJ Ryan <rryan@mixxx.org>2014-12-16 10:46:42 -0500
commitcc561ac98383395767af59f4a7711281cd0c20e5 (patch)
treea27d0ebbf648e6a15d13bc0f17a1b3dd5412dafb /src/library/library.cpp
parentda5ee7e7a238ccfde2046aaa5a222d309be5c877 (diff)
Add library font preference.
* Add font selector to the preferences. * Move row height preference from Interface to Library. * Add controls for changing the font size: - [Library],font_size_increment - [Library],font_size_decrement - [Library],font_size_knob If the row height is smaller than the font-size the larger of the two is used.
Diffstat (limited to 'src/library/library.cpp')
-rw-r--r--src/library/library.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/library/library.cpp b/src/library/library.cpp
index cc9cdb2f6a..675d910b34 100644
--- a/src/library/library.cpp
+++ b/src/library/library.cpp
@@ -38,13 +38,16 @@
// WLibrary
const QString Library::m_sTrackViewName = QString("WTrackTableView");
+// The default row height of the library.
+const int Library::kDefaultRowHeight = 20;
+
Library::Library(QObject* parent, ConfigObject<ConfigValue>* pConfig,
PlayerManagerInterface* pPlayerManager,
RecordingManager* pRecordingManager) :
m_pConfig(pConfig),
m_pSidebarModel(new SidebarModel(parent)),
m_pTrackCollection(new TrackCollection(pConfig)),
- m_pLibraryControl(new LibraryControl),
+ m_pLibraryControl(new LibraryControl(this)),
m_pRecordingManager(pRecordingManager) {
qRegisterMetaType<Library::RemovalType>("Library::RemovalType");
@@ -108,6 +111,16 @@ Library::Library(QObject* parent, ConfigObject<ConfigValue>* pConfig,
bool hasAccess = Sandbox::askForAccess(directory.canonicalFilePath());
qDebug() << "Checking for access to" << directoryPath << ":" << hasAccess;
}
+
+ m_iTrackTableRowHeight = m_pConfig->getValueString(
+ ConfigKey("[Library]", "RowHeight"),
+ QString::number(kDefaultRowHeight)).toInt();
+ QString fontStr = m_pConfig->getValueString(ConfigKey("[Library]", "Font"));
+ if (!fontStr.isEmpty()) {
+ m_trackTableFont.fromString(fontStr);
+ } else {
+ m_trackTableFont = QApplication::font();
+ }
}
Library::~Library() {
@@ -145,6 +158,10 @@ void Library::bindSidebarWidget(WLibrarySidebar* pSidebarWidget) {
connect(pSidebarWidget, SIGNAL(rightClicked(const QPoint&, const QModelIndex&)),
m_pSidebarModel, SLOT(rightClicked(const QPoint&, const QModelIndex&)));
+
+ pSidebarWidget->slotSetFont(m_trackTableFont);
+ connect(this, SIGNAL(setTrackTableFont(QFont)),
+ pSidebarWidget, SLOT(slotSetFont(QFont)));
}
void Library::bindWidget(WLibrary* pLibraryWidget,
@@ -166,6 +183,11 @@ void Library::bindWidget(WLibrary* pLibraryWidget,
connect(pTrackTableView, SIGNAL(trackSelected(TrackPointer)),
this, SIGNAL(trackSelected(TrackPointer)));
+ connect(this, SIGNAL(setTrackTableFont(QFont)),
+ pTrackTableView, SLOT(setTrackTableFont(QFont)));
+ connect(this, SIGNAL(setTrackTableRowHeight(int)),
+ pTrackTableView, SLOT(setTrackTableRowHeight(int)));
+
m_pLibraryControl->bindWidget(pLibraryWidget, pKeyboard);
QListIterator<LibraryFeature*> feature_it(m_features);
@@ -173,6 +195,11 @@ void Library::bindWidget(WLibrary* pLibraryWidget,
LibraryFeature* feature = feature_it.next();
feature->bindWidget(pLibraryWidget, pKeyboard);
}
+
+ // Set the current font and row height on all the WTrackTableViews that were
+ // just connected to us.
+ emit(setTrackTableFont(m_trackTableFont));
+ emit(setTrackTableRowHeight(m_iTrackTableRowHeight));
}
void Library::addFeature(LibraryFeature* feature) {
@@ -330,3 +357,13 @@ void Library::slotRequestRelocateDir(QString oldDir, QString newDir) {
QStringList Library::getDirs() {
return m_pTrackCollection->getDirectoryDAO().getDirs();
}
+
+void Library::slotSetTrackTableFont(const QFont& font) {
+ m_trackTableFont = font;
+ emit(setTrackTableFont(font));
+}
+
+void Library::slotSetTrackTableRowHeight(int rowHeight) {
+ m_iTrackTableRowHeight = rowHeight;
+ emit(setTrackTableRowHeight(rowHeight));
+}