diff --git a/ChangeLog b/ChangeLog index 765a033c..75351df1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21927,3 +21927,10 @@ * Added 'RDMainWindow' to rdcastmanager(1). 2021-06-19 Fred Gleason * Added 'RDMainWindow' to rdcatch(1). +2021-06-19 Fred Gleason + * Added 'RDCartFilter::setDragEnabled()', + 'RDCartFilter::showNoteBubbles()' and + 'RDCartFilter::setShowNoteBubbles()' methods. + * Removed 'RDCartFilter::loadConfig()' and 'RDCartFilter::saveConfig()' + methods. + * Added 'RDMainWindow' to rdlibrary(1). diff --git a/lib/rdcartfilter.cpp b/lib/rdcartfilter.cpp index f386e9a0..dce4abc2 100644 --- a/lib/rdcartfilter.cpp +++ b/lib/rdcartfilter.cpp @@ -199,32 +199,6 @@ QSizePolicy RDCartFilter::sizePolicy() const } -void RDCartFilter::loadConfig(RDProfile *p) -{ - d_shownotes_box->setChecked(p->boolValue("RDLibrary","ShowNoteBubbles",true)); - d_allowdrag_box-> - setChecked(p->boolValue("RDLibrary","AllowCartDragging",false)); -} - - -void RDCartFilter::saveConfig(FILE *f) const -{ - if(d_shownotes_box->isChecked()) { - fputs("Yes\n",f); - } - else { - fputs("No\n",f); - } - fprintf(f,"AllowCartDragging="); - if(d_allowdrag_box->isChecked()) { - fprintf(f,"Yes\n"); - } - else { - fprintf(f,"No\n"); - } -} - - QString RDCartFilter::filterSql(const QStringList &and_fields) const { QString sql=" where "; @@ -282,6 +256,12 @@ bool RDCartFilter::dragEnabled() const } +bool RDCartFilter::showNoteBubbles() const +{ + return d_shownotes_box->isChecked(); +} + + RDCart::Type RDCartFilter::showCartType() const { return d_show_cart_type; @@ -362,6 +342,18 @@ RDLibraryModel *RDCartFilter::model() const } +void RDCartFilter::setDragEnabled(bool state) +{ + return d_allowdrag_box->setChecked(state); +} + + +void RDCartFilter::setShowNoteBubbles(bool state) +{ + d_shownotes_box->setChecked(state); +} + + void RDCartFilter::setModel(RDLibraryModel *model) { connect(this,SIGNAL(filterChanged(const QString &)), diff --git a/lib/rdcartfilter.h b/lib/rdcartfilter.h index c9e451f7..f55eb197 100644 --- a/lib/rdcartfilter.h +++ b/lib/rdcartfilter.h @@ -41,13 +41,12 @@ class RDCartFilter : public RDWidget ~RDCartFilter(); QSize sizeHint() const; QSizePolicy sizePolicy() const; - void loadConfig(RDProfile *p); - void saveConfig(FILE *f) const; QString filterSql(const QStringList &and_fields=QStringList()) const; QString filterText() const; QString selectedGroup() const; QString selectedSchedCode() const; bool dragEnabled() const; + bool showNoteBubbles() const; RDCart::Type showCartType() const; void setShowCartType(RDCart::Type type); bool showTrackCarts() const; @@ -62,6 +61,8 @@ class RDCartFilter : public RDWidget static QString typeFilter(bool incl_audio,bool incl_macro,RDCart::Type mask); public slots: + void setDragEnabled(bool state); + void setShowNoteBubbles(bool state); void setModel(RDLibraryModel *model); void setFilterText(const QString &str); void setSelectedGroup(const QString &grpname); diff --git a/rdlibrary/Makefile.am b/rdlibrary/Makefile.am index 7c7be348..56704e45 100644 --- a/rdlibrary/Makefile.am +++ b/rdlibrary/Makefile.am @@ -57,6 +57,7 @@ dist_rdlibrary_SOURCES = audio_cart.cpp audio_cart.h\ libraryview.cpp libraryview.h\ list_reports.cpp list_reports.h\ macro_cart.cpp macro_cart.h\ + mainwindow.cpp mainwindow.h\ notebubble.cpp notebubble.h\ rdlibrary.cpp rdlibrary.h\ record_cut.cpp record_cut.h\ @@ -73,6 +74,7 @@ nodist_rdlibrary_SOURCES = moc_audio_cart.cpp\ moc_libraryview.cpp\ moc_list_reports.cpp\ moc_macro_cart.cpp\ + moc_mainwindow.cpp\ moc_notebubble.cpp\ moc_rdlibrary.cpp\ moc_record_cut.cpp diff --git a/rdlibrary/mainwindow.cpp b/rdlibrary/mainwindow.cpp new file mode 100644 index 00000000..7a352aa1 --- /dev/null +++ b/rdlibrary/mainwindow.cpp @@ -0,0 +1,66 @@ +// mainwindow.cpp +// +// Top-level window for rdlibrary(1) +// +// (C) Copyright 2021 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include "mainwindow.h" + +MainWindow::MainWindow(const QString &cmdname,RDConfig *c,Qt::WindowFlags f) + : RDMainWindow(cmdname,c,f) +{ + d_show_note_bubbles=false; + d_drag_enabled=false; +} + + +bool MainWindow::showNoteBubbles() const +{ + return d_show_note_bubbles; +} + + +void MainWindow::setShowNoteBubbles(bool state) +{ + d_show_note_bubbles=state; +} + + +bool MainWindow::dragEnabled() const +{ + return d_drag_enabled; +} + + +void MainWindow::setDragEnabled(bool state) +{ + d_drag_enabled=state; +} + + +void MainWindow::loadLocalSettings(RDProfile *p) +{ + d_show_note_bubbles=p->intValue(commandName(),"ShowNoteBubbles"); + d_drag_enabled=p->intValue(commandName(),"DragEnabled"); +} + + +void MainWindow::saveLocalSettings(FILE *f) const +{ + fprintf(f,"ShowNoteBubbles=%d\n",d_show_note_bubbles); + fprintf(f,"DragEnabled=%d\n",d_drag_enabled); +} diff --git a/rdlibrary/mainwindow.h b/rdlibrary/mainwindow.h new file mode 100644 index 00000000..05107fdb --- /dev/null +++ b/rdlibrary/mainwindow.h @@ -0,0 +1,46 @@ +// mainwindow.h +// +// Top-level window for rdlibrary(1) +// +// (C) Copyright 2021 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public +// License along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class MainWindow : public RDMainWindow +{ + Q_OBJECT; + public: + MainWindow(const QString &cmdname,RDConfig *c,Qt::WindowFlags f=0); + bool showNoteBubbles() const; + void setShowNoteBubbles(bool state); + bool dragEnabled() const; + void setDragEnabled(bool state); + + protected: + void loadLocalSettings(RDProfile *p); + void saveLocalSettings(FILE *f) const; + + private: + bool d_show_note_bubbles; + bool d_drag_enabled; +}; + + +#endif // MAINWINDOW_H diff --git a/rdlibrary/rdlibrary.cpp b/rdlibrary/rdlibrary.cpp index c8ac9c80..742a4ab7 100644 --- a/rdlibrary/rdlibrary.cpp +++ b/rdlibrary/rdlibrary.cpp @@ -55,7 +55,7 @@ bool audio_changed; void SigHandler(int signo); MainWidget::MainWidget(RDConfig *c,QWidget *parent) - : RDWidget(c,parent) + : MainWindow("rdlibrary",c) { QString err_msg; @@ -844,36 +844,20 @@ QString MainWidget::GeometryFile() { } } + void MainWidget::LoadGeometry() { - QString geometry_file=GeometryFile(); - if(geometry_file.isEmpty()) { - return; - } - RDProfile *profile=new RDProfile(); - profile->setSource(geometry_file); - resize(profile->intValue("RDLibrary","Width",sizeHint().width()), - profile->intValue("RDLibrary","Height",sizeHint().height())); - lib_cart_filter->loadConfig(profile); - - delete profile; + loadSettings(true); + lib_cart_filter->setDragEnabled(dragEnabled()); + lib_cart_filter->setShowNoteBubbles(showNoteBubbles()); } void MainWidget::SaveGeometry() { - QString geometry_file=GeometryFile(); - FILE *file=fopen(geometry_file.toUtf8(),"w"); - if(file==NULL) { - return; - } - fprintf(file,"[RDLibrary]\n"); - fprintf(file,"Width=%d\n",geometry().width()); - fprintf(file,"Height=%d\n",geometry().height()); - fprintf(file,"ShowNoteBubbles="); - lib_cart_filter->saveConfig(file); - - fclose(file); + setDragEnabled(lib_cart_filter->dragEnabled()); + setShowNoteBubbles(lib_cart_filter->showNoteBubbles()); + saveSettings(); } diff --git a/rdlibrary/rdlibrary.h b/rdlibrary/rdlibrary.h index 32692102..2c32f716 100644 --- a/rdlibrary/rdlibrary.h +++ b/rdlibrary/rdlibrary.h @@ -32,6 +32,7 @@ #include "disk_gauge.h" #include "libraryview.h" +#include "mainwindow.h" #define RDLIBRARY_GEOMETRY_FILE ".rdlibrary" #define RDLIBRARY_STEP_SIZE 5000 @@ -47,7 +48,7 @@ #define RDLIBRARY_USAGE "[--profile-ripping]\n\n--profile-ripping\n Print profiling information to stdout when performing rips from\n optical media.\n\n" -class MainWidget : public RDWidget +class MainWidget : public MainWindow { Q_OBJECT public: