MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), directory("/") { ui->setupUi(this); this->showFiles(); connect(ui->pushButton , SIGNAL(clicked()), this, SLOT(browseFiles())); }
//-------------------------------------------------------------------------- MainWindow::MainWindow() : settings(new Settings(this)), scanner(new Scanner(this)), engine(new SearchEngine(this)), mainMenu(new MainMenu(this)), status(new StatusBar(this)), stack(new QStackedWidget(this)), settingsDialog(new SettingsDialog(this)) { // Set up window widgets setWindowTitle(tr("Vaultaire")); setWindowIcon(QIcon(":/vaultaire.svg")); setMenuBar(mainMenu); setStatusBar(status); setCentralWidget(stack); // Connect signals to show scanning in-progress in status bar connect(scanner, SIGNAL(started()), status, SLOT(startBusyIndicator())); connect(scanner, SIGNAL(started()), this, SLOT(showScanningMessage())); connect(scanner, SIGNAL(finished(Scanner::ScanResult)), status, SLOT(stopBusyIndicator())); connect(scanner, SIGNAL(finished(Scanner::ScanResult)), status, SLOT(clearMessage())); // Connect signals to show search in-progress in status bar connect(engine, SIGNAL(started()), status, SLOT(startBusyIndicator())); connect(engine, SIGNAL(finished(QStringList)), status, SLOT(stopBusyIndicator())); // Create application widgets scanView = new ScanView(scanner, this); browser = new LibraryBrowser(this); search = new SearchView(engine, this); stack->addWidget(scanView); stack->addWidget(browser); stack->addWidget(search); // Connect menu signals connect(mainMenu, SIGNAL(scanNewFile()), this, SLOT(showScanForm())); connect(mainMenu, SIGNAL(browseFiles()), this, SLOT(showFileBrowser())); connect(mainMenu, SIGNAL(findFile()), this, SLOT(showSearchForm())); connect(mainMenu, SIGNAL(showAboutInfo()), this, SLOT(about())); connect(mainMenu, SIGNAL(quit()), this, SLOT(close())); connect(mainMenu, SIGNAL(editSettings()), settingsDialog, SLOT(show())); readSettings(); }
InputStrList::InputStrList( QGridLayout *layout,int &row, const QString & id, const QStringList &sl, ListMode lm, const QString & docs) : m_default(sl), m_strList(sl), m_docs(docs), m_id(id) { m_lab = new HelpLabel( id ); m_le = new QLineEdit; m_le->clear(); QToolBar *toolBar = new QToolBar; toolBar->setIconSize(QSize(24,24)); m_add = toolBar->addAction(QIcon(QString::fromAscii(":/images/add.png")),QString(), this,SLOT(addString())); m_add->setToolTip(tr("Add item")); m_del = toolBar->addAction(QIcon(QString::fromAscii(":/images/del.png")),QString(), this,SLOT(delString())); m_del->setToolTip(tr("Delete selected item")); m_upd = toolBar->addAction(QIcon(QString::fromAscii(":/images/refresh.png")),QString(), this,SLOT(updateString())); m_upd->setToolTip(tr("Update selected item")); m_lb = new QListWidget; //m_lb->setMinimumSize(400,100); foreach (QString s, m_strList) m_lb->addItem(s); m_brFile=0; m_brDir=0; if (lm!=ListString) { if (lm&ListFile) { m_brFile = toolBar->addAction(QIcon(QString::fromAscii(":/images/file.png")),QString(), this,SLOT(browseFiles())); m_brFile->setToolTip(tr("Browse to a file")); } if (lm&ListDir) { m_brDir = toolBar->addAction(QIcon(QString::fromAscii(":/images/folder.png")),QString(), this,SLOT(browseDir())); m_brDir->setToolTip(tr("Browse to a folder")); } } QHBoxLayout *rowLayout = new QHBoxLayout; rowLayout->addWidget( m_le ); rowLayout->addWidget( toolBar ); layout->addWidget( m_lab, row,0 ); layout->addLayout( rowLayout, row,1,1,2 ); layout->addWidget( m_lb, row+1,1,1,2 ); row+=2; m_value = m_strList; connect(m_le, SIGNAL(returnPressed()), this, SLOT(addString()) ); connect(m_lb, SIGNAL(currentTextChanged(const QString &)), this, SLOT(selectText(const QString &))); connect( m_lab, SIGNAL(enter()), SLOT(help()) ); connect( m_lab, SIGNAL(reset()), SLOT(reset()) ); }
InputStrList::InputStrList( const QString & label, QWidget *parent, QStrList &sl, ListMode lm) : QWidget(parent), strList(sl) { QGridLayout *layout = new QGridLayout( this, 2, 2, 5 ); lab = new QLabel( label, this ); lab->setMinimumSize( lab->sizeHint() ); layout->addWidget( lab,0,0 ); QWidget *dw = new QWidget(this); /* dummy widget used for layouting */ QHBoxLayout *boxlayout = new QHBoxLayout( dw, 0, 5 ); le = new QLineEdit( dw ); le->setMinimumSize( le->sizeHint() ); boxlayout->addWidget( le, 1 ); add = new QPushButton( dw ); //add->setPixmap( QPixmap( add_xpm )); add->setText( "+" ); add->setMinimumSize( add->sizeHint() ); QToolTip::add(add,"Add item"); boxlayout->addWidget( add ); del = new QPushButton( dw ); //del->setPixmap( QPixmap( del_xpm )); del->setText( "-" ); del->setMinimumSize( del->sizeHint() ); QToolTip::add(del,"Delete selected item"); boxlayout->addWidget( del ); upd = new QPushButton( dw ); //upd->setPixmap( QPixmap( update_xpm )); upd->setText( "*" ); upd->setMinimumSize( upd->sizeHint() ); QToolTip::add(upd,"Update selected item"); boxlayout->addWidget( upd ); lb = new QListBox( this ); lb->setMinimumSize(400,100); init(); lb->setVScrollBarMode(QScrollView::Auto); lb->setHScrollBarMode(QScrollView::Auto); brFile=0; brDir=0; if (lm!=ListString) { if (lm&ListFile) { brFile = new QPushButton(dw); //brFile->setPixmap( QPixmap(file_xpm) ); brFile->setText("Select..."); brFile->setMinimumSize(brFile->sizeHint()); QToolTip::add(brFile,"Browse to a file"); boxlayout->addWidget( brFile ); } if (lm&ListDir) { brDir = new QPushButton(dw); //brDir->setPixmap( QPixmap(folder_xpm) ); brDir->setText("Select..."); brDir->setMinimumSize(brDir->sizeHint()); QToolTip::add(brDir,"Browse to a folder"); boxlayout->addWidget( brDir ); } } layout->addWidget( dw, 0,1 ); layout->addWidget( lb,1,1 ); layout->activate(); setMinimumSize( sizeHint() ); connect(le, SIGNAL(returnPressed()), this, SLOT(addString()) ); connect(add, SIGNAL(clicked()), this, SLOT(addString()) ); connect(del, SIGNAL(clicked()), this, SLOT(delString()) ); connect(upd, SIGNAL(clicked()), this, SLOT(updateString()) ); if (brFile) { connect(brFile, SIGNAL(clicked()), this, SLOT(browseFiles())); } if (brDir) { connect(brDir, SIGNAL(clicked()), this, SLOT(browseDir())); } connect(lb, SIGNAL(selected(const QString &)), this, SLOT(selectText(const QString &))); }