MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ //for Signal/slot we must register the Typedef of QFileInfoList qRegisterMetaType<QFileInfoList>("QFileInfoList"); qRegisterMetaType< LFileInfoList >("LFileInfoList"); //just to silence/fix some Qt connect warnings in QtConcurrent qRegisterMetaType< QVector<int> >("QVector<int>"); qRegisterMetaType< QList<QPersistentModelIndex> >("QList<QPersistentModelIndex>"); ui->setupUi(this); if(DEBUG){ qDebug() << "Initilization:"; } settings = new QSettings( QSettings::UserScope, "lumina-desktop", "lumina-fm", this); //syncTimer = new QTimer(this); //syncTimer->setInterval(200); //1/5 second (collect as many signals/slots as necessary //syncTimer->setSingleShot(true); //Reset the UI to the previously used size (if possible) QSize orig = settings->value("preferences/MainWindowSize", QSize()).toSize(); if(!orig.isEmpty() && orig.isValid()){ //Make sure the old size is larger than the default size hint if(orig.width() < this->sizeHint().width()){ orig.setWidth(this->sizeHint().width()); } if(orig.height() < this->sizeHint().height()){ orig.setHeight(this->sizeHint().height()); } //Also ensure the old size is smaller than the current screen size QSize screen = QApplication::desktop()->availableGeometry(this).size(); if(orig.width() > screen.width()){ orig.setWidth(screen.width()); } if(orig.height() > screen.height()){ orig.setHeight(screen.height()); } //Now resize the window this->resize(orig); } //initialize the non-ui widgets if(DEBUG){ qDebug() << " - Tab Bar Setup"; } tabBar = new QTabBar(this); tabBar->setTabsClosable(true); tabBar->setMovable(true); //tabs are independant - so allow the user to sort them tabBar->setShape(QTabBar::RoundedNorth); tabBar->setFocusPolicy(Qt::NoFocus); static_cast<QBoxLayout*>(ui->centralwidget->layout())->insertWidget(0,tabBar); if(DEBUG){ qDebug() << " - Threading"; } workThread = new QThread; workThread->setObjectName("Lumina-fm filesystem worker"); worker = new DirData(); worker->zfsavailable = LUtils::isValidBinary("zfs"); connect(worker, SIGNAL(DirDataAvailable(QString, QString, LFileInfoList)), this, SLOT(DirDataAvailable(QString, QString, LFileInfoList)) ); connect(worker, SIGNAL(SnapshotDataAvailable(QString, QString, QStringList)), this, SLOT(SnapshotDataAvailable(QString, QString, QStringList)) ); worker->moveToThread(workThread); if(DEBUG){ qDebug() << " - File System Model"; } fsmod = new QFileSystemModel(this); fsmod->setRootPath(QDir::homePath()); dirCompleter = new QCompleter(fsmod, this); dirCompleter->setModelSorting( QCompleter::CaseInsensitivelySortedModel ); if(DEBUG){ qDebug() << " - Context Menu"; } contextMenu = new QMenu(this); radio_view_details = new QRadioButton(tr("Detailed List"), this); radio_view_list = new QRadioButton(tr("Basic List"), this); radio_view_tabs = new QRadioButton(tr("Prefer Tabs"), this); radio_view_cols = new QRadioButton(tr("Prefer Columns"), this); ui->menuView_Mode->clear(); ui->menuGroup_Mode->clear(); detWA = new QWidgetAction(this); detWA->setDefaultWidget(radio_view_details); listWA = new QWidgetAction(this); listWA->setDefaultWidget(radio_view_list); tabsWA = new QWidgetAction(this); tabsWA->setDefaultWidget(radio_view_tabs); colsWA = new QWidgetAction(this); colsWA->setDefaultWidget(radio_view_cols); ui->menuView_Mode->addAction(detWA); ui->menuView_Mode->addAction(listWA); ui->menuGroup_Mode->addAction(tabsWA); ui->menuGroup_Mode->addAction(colsWA); //Setup the pages //ui->BrowserLayout->clear(); ui->page_player->setLayout(new QVBoxLayout()); ui->page_image->setLayout(new QVBoxLayout()); MW = new MultimediaWidget(this); SW = new SlideshowWidget(this); ui->page_player->layout()->addWidget(MW); ui->page_image->layout()->addWidget(SW); //Setup any specialty keyboard shortcuts if(DEBUG){ qDebug() << " - Keyboard Shortcuts"; } nextTabLShort = new QShortcut( QKeySequence(tr("Shift+Left")), this); nextTabRShort = new QShortcut( QKeySequence(tr("Shift+Right")), this); togglehiddenfilesShort = new QShortcut( QKeySequence(tr("Ctrl+H")), this); //Finish loading the interface workThread->start(); if(DEBUG){ qDebug() << " - Icons"; } setupIcons(); if(DEBUG){ qDebug() << " - Connections"; } setupConnections(); if(DEBUG){ qDebug() << " - Settings"; } loadSettings(); if(DEBUG){ qDebug() << " - Bookmarks"; } RebuildBookmarksMenu(); if(DEBUG){ qDebug() << " - Devices"; } RebuildDeviceMenu(); //Make sure we start on the browser page if(DEBUG){ qDebug() << " - Load Browser Page"; } //goToBrowserPage(); if(DEBUG){ qDebug() << " - Done with init"; } }
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ //for Signal/slot we must register the Typedef of QFileInfoList qRegisterMetaType<QFileInfoList>("QFileInfoList"); qRegisterMetaType< LFileInfoList >("LFileInfoList"); ui->setupUi(this); if(DEBUG){ qDebug() << "Initilization:"; } //Be careful about the QSettings setup, it must match the lumina-desktop setup QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina"); settings = new QSettings( QSettings::UserScope, "LuminaDE", "lumina-fm", this); favdir = QDir::homePath()+"/.lumina/favorites/"; //save this for later //syncTimer = new QTimer(this); //syncTimer->setInterval(200); //1/5 second (collect as many signals/slots as necessary //syncTimer->setSingleShot(true); //Reset the UI to the previously used size (if possible) if(DEBUG){ qDebug() << " - Reset window size"; } int height = settings->value("geometry/height",-1).toInt(); if(height>100 && height <= QApplication::desktop()->availableGeometry(this).height()){ this->resize(this->width(), height); } int width = settings->value("geometry/width",-1).toInt(); if(width>100 && width <= QApplication::desktop()->availableGeometry(this).width()){ this->resize(width, this->height() ); } //initialize the non-ui widgets if(DEBUG){ qDebug() << " - Tab Bar Setup"; } tabBar = new QTabBar(this); tabBar->setTabsClosable(true); tabBar->setMovable(true); //tabs are independant - so allow the user to sort them tabBar->setShape(QTabBar::RoundedNorth); tabBar->setFocusPolicy(Qt::NoFocus); static_cast<QBoxLayout*>(ui->centralwidget->layout())->insertWidget(0,tabBar); if(DEBUG){ qDebug() << " - Threading"; } workThread = new QThread; workThread->setObjectName("Lumina-fm filesystem worker"); worker = new DirData(); worker->zfsavailable = LUtils::isValidBinary("zfs"); connect(worker, SIGNAL(DirDataAvailable(QString, QString, LFileInfoList)), this, SLOT(DirDataAvailable(QString, QString, LFileInfoList)) ); connect(worker, SIGNAL(SnapshotDataAvailable(QString, QString, QStringList)), this, SLOT(SnapshotDataAvailable(QString, QString, QStringList)) ); worker->moveToThread(workThread); if(DEBUG){ qDebug() << " - File System Model"; } fsmod = new QFileSystemModel(this); fsmod->setRootPath(QDir::homePath()); dirCompleter = new QCompleter(fsmod, this); dirCompleter->setModelSorting( QCompleter::CaseInsensitivelySortedModel ); if(DEBUG){ qDebug() << " - Context Menu"; } contextMenu = new QMenu(this); radio_view_details = new QRadioButton(tr("Detailed List"), this); radio_view_list = new QRadioButton(tr("Basic List"), this); radio_view_tabs = new QRadioButton(tr("Prefer Tabs"), this); radio_view_cols = new QRadioButton(tr("Prefer Columns"), this); ui->menuView_Mode->clear(); ui->menuGroup_Mode->clear(); detWA = new QWidgetAction(this); detWA->setDefaultWidget(radio_view_details); listWA = new QWidgetAction(this); listWA->setDefaultWidget(radio_view_list); tabsWA = new QWidgetAction(this); tabsWA->setDefaultWidget(radio_view_tabs); colsWA = new QWidgetAction(this); colsWA->setDefaultWidget(radio_view_cols); ui->menuView_Mode->addAction(detWA); ui->menuView_Mode->addAction(listWA); ui->menuGroup_Mode->addAction(tabsWA); ui->menuGroup_Mode->addAction(colsWA); //Setup the pages //ui->BrowserLayout->clear(); ui->page_player->setLayout(new QVBoxLayout()); ui->page_image->setLayout(new QVBoxLayout()); MW = new MultimediaWidget(this); SW = new SlideshowWidget(this); ui->page_player->layout()->addWidget(MW); ui->page_image->layout()->addWidget(SW); //Setup any specialty keyboard shortcuts if(DEBUG){ qDebug() << " - Keyboard Shortcuts"; } nextTabLShort = new QShortcut( QKeySequence(tr("Shift+Left")), this); nextTabRShort = new QShortcut( QKeySequence(tr("Shift+Right")), this); closeTabShort = new QShortcut( QKeySequence(tr("Ctrl+W")), this); //Finish loading the interface workThread->start(); if(DEBUG){ qDebug() << " - Icons"; } setupIcons(); if(DEBUG){ qDebug() << " - Connections"; } setupConnections(); if(DEBUG){ qDebug() << " - Settings"; } loadSettings(); if(DEBUG){ qDebug() << " - Bookmarks"; } RebuildBookmarksMenu(); if(DEBUG){ qDebug() << " - Devices"; } RebuildDeviceMenu(); //Make sure we start on the browser page if(DEBUG){ qDebug() << " - Load Browser Page"; } //goToBrowserPage(); if(DEBUG){ qDebug() << " - Done with init"; } }