Commits

piorekf  committed ad0e8d1

Added possibility to change font in library view

  • Participants
  • Parent commits c7f5819

Comments (0)

Files changed (6)

File plug/library.cpp

     restoreGeometry(settings.value("Windows/libraryWindowGeometry").toByteArray());
 
     files = new QList<QFileInfo>();
+    ui->spinBox->setValue(ui->listWidget->font().pointSize());
+    ui->fontComboBox->setCurrentFont(ui->listWidget->font());
 
     connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(load_slot(int)));
     connect(ui->listWidget_2, SIGNAL(currentRowChanged(int)), this, SLOT(load_file(int)));
     connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(get_directory()));
     connect(this, SIGNAL(directory_changed(QString)), ui->label_3, SLOT(setText(QString)));
     connect(this, SIGNAL(directory_changed(QString)), this, SLOT(get_files(QString)));
+    connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(change_font_size(int)));
+    connect(ui->fontComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(change_font_family(QFont)));
 }
 
 Library::~Library()
 {
     ui->label_3->setMaximumWidth((event->size().width()/2)-ui->pushButton->size().width());
 }
+
+void Library::change_font_size(int value)
+{
+    QFont font(ui->listWidget_2->font());
+    font.setPointSize(value);
+    ui->listWidget->setFont(font);
+    ui->listWidget_2->setFont(font);
+}
+
+void Library::change_font_family(QFont font)
+{
+    font.setPointSize(ui->spinBox->value());
+    ui->listWidget->setFont(font);
+    ui->listWidget_2->setFont(font);
+}

File plug/library.h

     void get_directory();
     void get_files(QString);
     void load_file(int);
+    void change_font_size(int);
+    void change_font_family(QFont);
 
 signals:
     void directory_changed(QString);

File plug/library.ui

   <property name="windowTitle">
    <string>PLUG Library</string>
   </property>
-  <layout class="QHBoxLayout" name="horizontalLayout_2">
+  <layout class="QVBoxLayout" name="verticalLayout_3">
    <item>
-    <layout class="QVBoxLayout" name="verticalLayout">
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
      <item>
-      <widget class="QLabel" name="label">
+      <layout class="QVBoxLayout" name="verticalLayout">
+       <item>
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>&amp;Amplifier:</string>
+         </property>
+         <property name="buddy">
+          <cstring>listWidget</cstring>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QListWidget" name="listWidget"/>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>&amp;Files from:</string>
+         </property>
+         <property name="buddy">
+          <cstring>listWidget_2</cstring>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <item>
+          <widget class="QLabel" name="label_3">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text">
+            <string>[choose directory]</string>
+           </property>
+           <property name="textInteractionFlags">
+            <set>Qt::TextSelectableByMouse</set>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QPushButton" name="pushButton">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text">
+            <string>&amp;...</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QListWidget" name="listWidget_2"/>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_4">
        <property name="text">
-        <string>&amp;Amplifier:</string>
+        <string>F&amp;ont</string>
        </property>
        <property name="buddy">
-        <cstring>listWidget</cstring>
+        <cstring>fontComboBox</cstring>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QListWidget" name="listWidget"/>
+      <widget class="QFontComboBox" name="fontComboBox"/>
      </item>
-    </layout>
-   </item>
-   <item>
-    <layout class="QVBoxLayout" name="verticalLayout_2">
      <item>
-      <widget class="QLabel" name="label_2">
+      <widget class="QLabel" name="label_5">
        <property name="text">
-        <string>&amp;Files from:</string>
+        <string>&amp;Size</string>
        </property>
        <property name="buddy">
-        <cstring>listWidget_2</cstring>
+        <cstring>spinBox</cstring>
        </property>
       </widget>
      </item>
      <item>
-      <layout class="QHBoxLayout" name="horizontalLayout">
-       <item>
-        <widget class="QLabel" name="label_3">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="text">
-          <string>[choose directory]</string>
-         </property>
-         <property name="textInteractionFlags">
-          <set>Qt::TextSelectableByMouse</set>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="pushButton">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="text">
-          <string>&amp;...</string>
-         </property>
-        </widget>
-       </item>
-      </layout>
+      <widget class="QSpinBox" name="spinBox">
+       <property name="maximum">
+        <number>32</number>
+       </property>
+      </widget>
      </item>
      <item>
-      <widget class="QListWidget" name="listWidget_2"/>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
      </item>
     </layout>
    </item>

File plug/mainwindow.cpp

     char names[24][32];
     bool previous = settings.value("Settings/popupChangedWindows").toBool();
 
-    if(!connected)
-        return;
-
     settings.setValue("Settings/popupChangedWindows", false);
 
     library = new Library(this);
     ui->statusBar->showMessage("", 1);
     if(ret == -100)
     {
-        ui->statusBar->showMessage(tr("Suitable device not found!"), 5000);
+        ui->statusBar->showMessage(tr("Error: Suitable device not found!"), 5000);
         return;
     }
     else if(ret)
         ui->statusBar->showMessage(QString(tr("Communication error: %1")).arg(ret), 5000);
         return;
     }
-    QMessageBox::information(this, "Update finished", "Update finished<br>If \"Exit\" button is lit - update was succesful<br>If \"Save\" button is lit - update failed<br><br>Power off the amplifier and then back on to finish the process.");
+    QMessageBox::information(this, "Update finished", "<b>Update finished</b><br>If \"Exit\" button is lit - update was succesful<br>If \"Save\" button is lit - update failed<br><br>Power off the amplifier and then back on to finish the process.");
 }

File plug/mustang.cpp

     FILE *file;
     file = fopen(filename, "rb");
     struct timespec sleep;
-    sleep.tv_nsec = 10000000;
+    sleep.tv_nsec = NANO_SEC_SLEEP;
     sleep.tv_sec = 0;
 
     if(amp_hand == NULL)

File plug/mustang.h

 // for USB communication
 #define TMOUT 500
 #define LENGTH 64
+#define NANO_SEC_SLEEP 10000000
 
 // effect array fields
 #define DSP 2