Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add some more work to pc-devicemanager. It should now compile/run, bu…

…t the GUI is not actually hooked up to anything yet.
  • Loading branch information...
commit 957dd886f513a86fc04db68144d12bbebe97746c 1 parent a5cc065
@beanpole135 beanpole135 authored
View
17 pc-devicemanager/Backend.h
@@ -0,0 +1,17 @@
+#ifndef _PC_DEVMANAGER_BACKEND_H
+#define _PC_DEVMANAGER_BACKEND_H
+
+class Backend{
+public:
+ //Listing Groups of devices
+ static QStringList listDevices(QString filter, bool topLevelOnly = true);
+ static QStringList listDeviceInfo(QStringList devs);
+ //Single Device Options
+
+private:
+ //Utility functions for running QProcesses
+ static QStringList cmdOutput(QString cmd);
+ static int runCmd(QString cmd);
+
+};
+#endif
View
43 pc-devicemanager/main.cpp
@@ -0,0 +1,43 @@
+#include <QTranslator>
+#include <qtsingleapplication.h>
+#include <QtGui/QApplication>
+#include <QMessageBox>
+#include <QDebug>
+#include <QFile>
+
+#include "mainUI.h"
+
+#ifndef PREFIX
+#define PREFIX QString("/usr/local/")
+#endif
+
+int main(int argc, char ** argv)
+{
+ QtSingleApplication a(argc, argv);
+ if( a.isRunning() )
+ return !(a.sendMessage("show"));
+
+ QTranslator translator;
+ QLocale mylocale;
+ QString langCode = mylocale.name();
+
+ if ( ! QFile::exists(PREFIX + "/share/pcbsd/i18n/pc-devicemanager_" + langCode + ".qm" ) ) langCode.truncate(langCode.indexOf("_"));
+ translator.load( QString("pc-devicemanager_") + langCode, PREFIX + "/share/pcbsd/i18n/" );
+ a.installTranslator( &translator );
+ qDebug() << "Locale:" << langCode;
+
+
+ mainUI w;
+ QObject::connect(&a, SIGNAL(messageReceived(const QString&)), &w, SLOT(slotSingleInstance()) );
+ w.show();
+ //Check for root
+ if (0 != geteuid())
+ {
+ QMessageBox msg;
+ msg.setText(w.tr("This application requires administrator privileges for operation."));
+ msg.exec();
+ exit(2);
+ }
+ int retCode = a.exec();
+ return retCode;
+}
View
74 pc-devicemanager/mainUI.cpp
@@ -3,9 +3,83 @@
mainUI::mainUI() : QMainWindow(), ui(new Ui::mainUI){
ui->setupUi(this); //load the designer template
+ //Setup the removable devices change list
+ QStringList rdactions; rdactions << tr("Format Device");
+ ui->combo_rd_changelist->addItems(rdactions);
+ ui->combo_rd_changelist->setIndex(0);
+ //Setup the format removable device filesystem list
+ QStringList rdfilesys; rdfilesys << tr("FAT32 (Recommended)") << tr("UFS (PC-BSD/FreeBSD only)");
+ ui->combo_rd_format_fs->addItems(rdfilesys);
}
mainUI::~mainUI(){
+ delete ui;
+}
+
+void mainUI::slotSingleInstance(){
+ this->show();
+ this->raise();
+}
+
+// ==================
+// PRIVATE FUNCTIONS
+// ==================
+void mainUI::updateRemovableDeviceList(){
+
+}
+
+// ==================
+// PRIVATE SLOTS
+// ==================
+void mainUI::on_actionQuit_triggered(){
+ this->close();
+}
+
+// ==== REMOVABLE DEVICES TAB ====
+void mainUI::on_combo_rd_devices_currentIndexChanged(QString txt){
+
+}
+
+void mainUI::on_combo_rd_changelist_currentIndexChanged(int index){
+ if(index == 0){
+ //Show the disk format page
+ ui->stack_rd_changepages->setCurrentWidget(ui->page_reformat);
+ }
+}
+
+//-------- FORMAT REMOVABLE DEVICE ---------
+void mainUI::on_tool_rd_reformatdevice_clicked(){
+ //Get the UI inputs
+ QString label = ui->line_rd_format_label->text();
+ QString filesys;
+ if(ui->combo_rd_format_fs->currentIndex() == 0){ filesys = "FAT32"; }
+ else if(ui->combo_rd_format_fs->currentIndex() == 1){ filesys = "UFS"; }
+ QString device = ui->combo_rd_devices->currentText().section("<",0,0).simplified();
+ if(!device.startsWith("/dev/")){ device.prepend("/dev/"); }
+ //Check for valid inputs
+ if(!QFile::exists(device) || Backend::isMounted(device)){
+ QMessageBox::warning(this,tr("Invalid Device"),tr("The device is not longer attached. Please refresh the list of available devices and pick a different one.") );
+ return;
+ }else if(Backend::isMounted(device)){
+ QMessageBox::warning(this,tr("Device Currently Mounted"),tr("The device is currently mounted and/or in use. Please unmount the device first and try again.") );
+ return;
+ }else if(filesys.isEmpty()){
+ QMessageBox::warning(this,tr("Invalid Filesystem"),tr("Please select a filesystem for the device and try again.") );
+ return;
+ }
+ //Verify the format action
+ QString summary = QString(tr("Device: %1")).arg(device) +"\n"+QString(tr("New Label: %1")).arg(label)+"\n"+QString(tr("FileSystem: %1")).arg(filesys);
+ if( QMessageBox::Yes != QMessageBox::question(this,tr("Verify Format Procedure"),
+ tr("Are you sure you wish to format this device? All data currently on this device will be permanently erased.") +"\n"+summary,
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ return; }
+ //Format the device
+ //put up a "working" dialog
+
+ //call the backend
+
+ //close the "working" dialog
+
+ //Display results
}
View
14 pc-devicemanager/mainUI.h
@@ -2,6 +2,9 @@
#define _PC_DEVICEMANAGER_H
#include <QMainWindow>
+#include <QString>
+#include <QMessageBox>
+#include <QFile>
namespace Ui{
class mainUI;
@@ -13,10 +16,17 @@ class mainUI : public QMainWindow{
mainUI();
~mainUI();
+public slots:
+ void slotSingleInstance();
+
private:
Ui::mainUI *ui;
+ void updateRemovableDeviceList();
private slots:
-
+ void on_actionQuit_triggered();
+ void on_combo_rd_devices_currentIndexChanged(QString);
+ void on_combo_rd_changelist_currentIndexChanged(int);
+ void on_tool_rd_reformatdevice_clicked();
};
-#endif
+#endif
View
62 pc-devicemanager/mainUI.ui
@@ -28,7 +28,17 @@
</font>
</property>
<property name="text">
- <string>WARNING: Everything changed here is permanent. Use extreme caution!!</string>
+ <string>WARNING: Everything changed here is permanent.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Make sure that you have your data backed up elsewhere first!</string>
</property>
</widget>
</item>
@@ -38,6 +48,10 @@
<number>0</number>
</property>
<widget class="QWidget" name="tab_removable">
+ <attribute name="icon">
+ <iconset resource="pc-devicemanager.qrc">
+ <normaloff>:/images/usb.png</normaloff>:/images/usb.png</iconset>
+ </attribute>
<attribute name="title">
<string>Removable Devices</string>
</attribute>
@@ -151,7 +165,7 @@
<item>
<widget class="QComboBox" name="combo_rd_changelist">
<property name="statusTip">
- <string>Available </string>
+ <string>Possible changes for the selected device</string>
</property>
</widget>
</item>
@@ -162,6 +176,9 @@
</property>
<widget class="QWidget" name="page_reformat">
<layout class="QFormLayout" name="formLayout_3">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@@ -177,6 +194,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="statusTip">
+ <string>The new name by which to recognize the device.</string>
+ </property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly|Qt::ImhLowercaseOnly|Qt::ImhPreferUppercase|Qt::ImhUppercaseOnly</set>
</property>
@@ -193,16 +213,26 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QComboBox" name="combo_rd_format_fs"/>
+ <widget class="QComboBox" name="combo_rd_format_fs">
+ <property name="statusTip">
+ <string>The new filesystem to put on the device</string>
+ </property>
+ </widget>
</item>
<item row="2" column="1">
- <widget class="QCheckBox" name="check_rd_format_cleandev">
- <property name="text">
- <string>Completely Clean Device First</string>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
- </widget>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
</item>
- <item row="4" column="1">
+ <item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer">
@@ -219,6 +249,9 @@
</item>
<item>
<widget class="QToolButton" name="tool_rd_reformatdevice">
+ <property name="statusTip">
+ <string>Start the process of formatting the device</string>
+ </property>
<property name="text">
<string>Format Device</string>
</property>
@@ -233,19 +266,6 @@
</item>
</layout>
</item>
- <item row="3" column="1">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
View
BIN  pc-devicemanager/pc-devicemanager.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
92 pc-devicemanager/pc-devicemanager.pro
@@ -0,0 +1,92 @@
+QT += core gui
+
+TARGET = pc-devicemanager
+target.path = /usr/local/bin
+
+TEMPLATE = app
+
+
+SOURCES += main.cpp mainUI.cpp
+
+
+HEADERS += mainUI.h
+
+
+FORMS += mainUI.ui
+
+
+RESOURCES+= pc-devicemanager.qrc
+
+LIBS += -lQtSolutions_SingleApplication-head
+
+TRANSLATIONS = i18n/pc-devicemanager_af.ts \
+ i18n/pc-devicemanager_ar.ts \
+ i18n/pc-devicemanager_az.ts \
+ i18n/pc-devicemanager_bg.ts \
+ i18n/pc-devicemanager_bn.ts \
+ i18n/pc-devicemanager_bs.ts \
+ i18n/pc-devicemanager_ca.ts \
+ i18n/pc-devicemanager_cs.ts \
+ i18n/pc-devicemanager_cy.ts \
+ i18n/pc-devicemanager_da.ts \
+ i18n/pc-devicemanager_de.ts \
+ i18n/pc-devicemanager_el.ts \
+ i18n/pc-devicemanager_en_GB.ts \
+ i18n/pc-devicemanager_en_ZA.ts \
+ i18n/pc-devicemanager_es.ts \
+ i18n/pc-devicemanager_et.ts \
+ i18n/pc-devicemanager_eu.ts \
+ i18n/pc-devicemanager_fa.ts \
+ i18n/pc-devicemanager_fi.ts \
+ i18n/pc-devicemanager_fr.ts \
+ i18n/pc-devicemanager_fr_CA.ts \
+ i18n/pc-devicemanager_gl.ts \
+ i18n/pc-devicemanager_he.ts \
+ i18n/pc-devicemanager_hi.ts \
+ i18n/pc-devicemanager_hr.ts \
+ i18n/pc-devicemanager_hu.ts \
+ i18n/pc-devicemanager_id.ts \
+ i18n/pc-devicemanager_is.ts \
+ i18n/pc-devicemanager_it.ts \
+ i18n/pc-devicemanager_ja.ts \
+ i18n/pc-devicemanager_ka.ts \
+ i18n/pc-devicemanager_ko.ts \
+ i18n/pc-devicemanager_lt.ts \
+ i18n/pc-devicemanager_lv.ts \
+ i18n/pc-devicemanager_mk.ts \
+ i18n/pc-devicemanager_mn.ts \
+ i18n/pc-devicemanager_ms.ts \
+ i18n/pc-devicemanager_mt.ts \
+ i18n/pc-devicemanager_nb.ts \
+ i18n/pc-devicemanager_nl.ts \
+ i18n/pc-devicemanager_pa.ts \
+ i18n/pc-devicemanager_pl.ts \
+ i18n/pc-devicemanager_pt.ts \
+ i18n/pc-devicemanager_pt_BR.ts \
+ i18n/pc-devicemanager_ro.ts \
+ i18n/pc-devicemanager_ru.ts \
+ i18n/pc-devicemanager_sa.ts \
+ i18n/pc-devicemanager_sk.ts \
+ i18n/pc-devicemanager_sl.ts \
+ i18n/pc-devicemanager_sr.ts \
+ i18n/pc-devicemanager_sv.ts \
+ i18n/pc-devicemanager_sw.ts \
+ i18n/pc-devicemanager_ta.ts \
+ i18n/pc-devicemanager_tg.ts \
+ i18n/pc-devicemanager_th.ts \
+ i18n/pc-devicemanager_tr.ts \
+ i18n/pc-devicemanager_uk.ts \
+ i18n/pc-devicemanager_uz.ts \
+ i18n/pc-devicemanager_vi.ts \
+ i18n/pc-devicemanager_zh_CN.ts \
+ i18n/pc-devicemanager_zh_HK.ts \
+ i18n/pc-devicemanager_zh_TW.ts \
+ i18n/pc-devicemanager_zu.ts
+
+dotrans.path=/usr/local/share/pcbsd/i18n/
+dotrans.extra=cd i18n && lrelease-qt4 -nounfinished *.ts && cp *.qm /usr/local/share/pcbsd/i18n/
+
+icons.files = pc-devicemanager.png
+icons.path=/usr/local/share/pcbsd/icons/
+
+INSTALLS += target icons dotrans
Please sign in to comment.
Something went wrong with that request. Please try again.