FileView::FileView(QWidget *parent) : QWidget(parent), ui(new Ui::FileView) { ui->setupUi(this); ui->lineEdit->setIconPixmap(QPixmap(":splash/img/up.png")); ui->lineEdit->setIconVisibility(IconizedLineEdit::IconAlwaysVisible); mMenu = new QMenu(this); mMenu->addAction("Empty1"); mMenu->addAction("Empty2"); mMenu->addAction("Empty3"); mFileMenu = new QMenu(this); mFileMenu->addAction("File1"); mFileMenu->addAction("File2"); mFileMenu->addAction("File3"); mDirMenu = new QMenu(this); mDirMenu->addAction("Dir1"); mDirMenu->addAction("Dir2"); mDirMenu->addAction("Dir3"); mFileModel = new QFileSystemModel(this); mRootPath = "My Computer"; mFileModel->setRootPath(mRootPath); ui->listView->setModel(mFileModel); ExplorerItemDelegate *lDeltegate = new ExplorerItemDelegate(); lDeltegate->setFileSystemModel(mFileModel); ui->listView->setItemDelegate(lDeltegate); ui->listView->setViewMode(QListView::IconMode); ui->listView->setMovement(QListView::Static); ui->listView->setResizeMode(QListView::Adjust); ui->listView->setFlow(QListView::LeftToRight); ui->listView->setWordWrap(true); ui->listView->setWrapping(true); ui->listView->setGridSize(QSize(70,70)); ui->listView->setRootIndex(mFileModel->index(mRootPath)); ui->listView->setAcceptDrops(true); ui->listView->setDragEnabled(true); ui->listView->setDragDropMode(QAbstractItemView::DragDrop); ui->listView->setContextMenuPolicy(Qt::CustomContextMenu); ui->lineEdit->setText(mRootPath); connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)), SLOT(slotDoubleClick(QModelIndex))); connect(ui->listView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotRightBtnClick(QPoint))); connect(ui->lineEdit, SIGNAL(signalIconClicked()), SLOT(slotGoUp())); }
void QvvMainWindow::setupMenuBar() { /*--------------------------------------------------------------------*/ QMenu *menu; toolbar = new QToolBar( this ); toolbar->setVisible( opt_use_toolbar ? 1 : 0 ); menu = menuBar()->addMenu( tr("&File") ); QAction *action; /* action = menu->addAction(tr("Save layout...")); connect(action, SIGNAL(triggered()), this, SLOT(saveLayout())); action = menu->addAction(tr("Load layout...")); connect(action, SIGNAL(triggered()), this, SLOT(loadLayout())); action = menu->addAction(tr("Switch layout direction")); connect(action, SIGNAL(triggered()), this, SLOT(switchLayoutDirection())); menu->addSeparator(); */ action = menu->addAction( tr("&Reload directory"), this, SLOT(slotReloadDir()), Qt::Key_F5 ); action->setIcon( QIcon( ":/images/view-refresh.png" ) ); action = menu->addAction( tr("&Delete selected images"), this, SLOT(slotDeleteSelected()), Qt::Key_Delete ); //action->setIcon( QIcon( ":/images/view-refresh.png" ) ); action = menu->addAction( tr("&Quit"), this, SLOT(close()), Qt::AltModifier + Qt::Key_X ); action->setIcon( QIcon( ":/images/system-log-out.png" ) ); /*--------------------------------------------------------------------*/ menu = menuBar()->addMenu( tr("&View")); action = menu->addAction( tr("&Toggle toolbar"), this, SLOT(slotToggleToolbar()) ); action = menu->addAction( tr("Enable &thumbnails") ); action->setCheckable( true ); action->setChecked( opt_thumbs ); action->setShortcut( Qt::Key_F6 ); connect( action, SIGNAL( toggled(bool) ), this, SLOT(slotThumbs()) ); action = menu->addAction( tr("Show d&irectories only") ); action->setCheckable( true ); action->setChecked( opt_dirs_only ); action->setShortcut( Qt::AltModifier + Qt::Key_I ); connect( action, SIGNAL( toggled(bool) ), this, SLOT(slotShowDirsOnly()) ); menu->addSeparator(); action = menu->addAction( tr("Sort by &Name"), this, SLOT(slotSortColumn1()), Qt::AltModifier + Qt::Key_N ); action = menu->addAction( tr("Sort by &Modify Time"), this, SLOT(slotSortColumn3()), Qt::AltModifier + Qt::Key_M ); /*--------------------------------------------------------------------*/ menu = menuBar()->addMenu( tr("&Go")); action = menu->addAction( tr("Go to p&arent directory"), this, SLOT(slotGoUp()), Qt::Key_Backspace ); action->setIcon( QIcon( ":/images/go-up.png" ) ); toolbar->addAction( action ); action = menu->addAction( tr("Change &directory"), this, SLOT(slotChangeDir()), Qt::AltModifier + Qt::Key_D ); action->setIcon( QIcon( ":/images/folder.png" ) ); toolbar->addAction( action ); action = menu->addAction( tr("Go to &home directory"), this, SLOT(slotHomeDir()), Qt::AltModifier + Qt::Key_Home ); action->setIcon( QIcon( ":/images/go-home.png" ) ); toolbar->addAction( action ); menu->addSeparator(); action = menu->addAction( tr("Go to &Random image"), this, SLOT(slotRandomItem()), Qt::Key_Asterisk ); action = menu->addAction( tr("Activate current item"), this, SLOT(enterCurrent()), Qt::Key_Right ); action = menu->addAction( tr("Display all &selected images"), this, SLOT(enterAllSelected()), Qt::ControlModifier + Qt::Key_Right ); action->setIcon( QIcon( ":/images/view_all.png" ) ); toolbar->addAction( action ); /*--------------------------------------------------------------------*/ menu = menuBar()->addMenu( tr("&Window")); action = menu->addAction( tr("&New browser window"), this, SLOT(slotNewWindow()), Qt::Key_F3 ); action->setIcon( QIcon( ":/images/window-new.png" ) ); toolbar->addAction( action ); menu->addAction( tr("&Close window"), this, SLOT(close()), Qt::Key_F4 ); /*--------------------------------------------------------------------*/ menu = menuBar()->addMenu( tr("&Settings")); action = menu->addAction( tr("Create thumbnails if needed") ); action->setCheckable( true ); action->setChecked( opt_create_thumbs ); connect( action, SIGNAL( toggled(bool) ), this, SLOT(slotCreateThumbs()) ); action = menu->addAction( tr("Create smooth thumbnails") ); action->setCheckable( true ); action->setChecked( opt_create_smooth_thumbs ); connect( action, SIGNAL( toggled(bool) ), this, SLOT(slotSmoothThumbs()) ); action = menu->addAction( tr("Create new thumbnails in JPEG for JPEGs") ); action->setCheckable( true ); action->setChecked( opt_create_jpeg_thumbs ); connect( action, SIGNAL( toggled(bool) ), this, SLOT(slotJPEGThumbs()) ); menu->addSeparator(); action = menu->addAction( tr("Use toolbar upon startup") ); action->setCheckable( true ); action->setChecked( opt_use_toolbar ); connect( action, SIGNAL( toggled(bool) ), this, SLOT(slotUseToolbar()) ); /*--------------------------------------------------------------------*/ menu = menuBar()->addMenu( tr("&Help") ); action = menu->addAction( tr("&Help Contents"), this, SLOT(slotHelp()), Qt::Key_F1 ); action->setIcon( QIcon( ":/images/help-browser.png" ) ); toolbar->addAction( action ); action = menu->addAction( tr("&About"), this, SLOT(slotAbout()), Qt::AltModifier + Qt::Key_A ); action->setIcon( QIcon( ":/images/face-glasses.png" ) ); toolbar->addAction( action ); /*--------------------------------------------------------------------*/ addToolBar( toolbar ); }
void QvvMainWindow::keyPressEvent ( QKeyEvent * e ) { e->accept(); if( e->modifiers() & Qt::CTRL ) { switch( e->key() ) { case Qt::Key_Right : enterAllSelected(); break; default: e->ignore(); QMainWindow::keyPressEvent( e ); break; } } else if( e->modifiers() & Qt::ALT ) { switch( e->key() ) { default: e->ignore(); QMainWindow::keyPressEvent( e ); break; } } else { switch( e->key() ) { case Qt::Key_F1: slotHelp(); break; /* case Qt::Key_F3 : slotNewWindow(); break; case Qt::Key_F4 : close(); delete this; break; */ case Qt::Key_Left : slotGoUp(); break; case Qt::Key_Right : enter( tree->currentItem() ); break; case Qt::Key_BracketLeft : slotGoPrev(); break; case Qt::Key_Space : case Qt::Key_BracketRight : slotGoNext(); break; /* case Qt::Key_F1 : closeAll(); views.append( new qvvView( this ) ); views.first()->load( "*logo*" ); break; case Qt::Key_F5 : loadDir( cdir.absolutePath() ); break; case Qt::Key_BracketLeft : slotGoPrev(); break; case Qt::Key_BracketRight : slotGoNext(); break; case Qt::Key_Backspace : case Qt::Key_Escape : closeAll(); break; case Qt::Key_Insert : optCenter = !optCenter; break; case Qt::Key_Delete : slotDelete(); break; */ /* default: if ( e->text().toAscii().at(0) && isalnum(e->text().toAscii().at(0)) ) find( e->text().toAscii().at(0) ); else switch( e->text().toAscii().at(0) ) { case 13 : Enter( tree->currentItem() ); break; case '~' : goToDir( '~' ); break; case '`' : goToDir( '`' ); break; default: QMainWindow::keyPressEvent( e ); } */ default: if( e->text() == "" ) QWidget::keyPressEvent( e ); else switch( e->text().toAscii().at(0) ) { case '[' : slotGoPrev(); break; case ']' : slotGoNext(); break; case '~' : slotHomeDir(); break; case '`' : slotChangeDir(); break; default: e->ignore(); QMainWindow::keyPressEvent( e ); break; } } } }