void MainWindow::createAction(){ _open = new QAction(QIcon(":/image/Open.png"), tr("&Open..."), this); _open->setShortcuts(QKeySequence::Open); _open->setStatusTip(QString::fromUtf8("フォルダを開く")); connect(_open, SIGNAL(triggered()), this, SLOT(openDir())); _save = new QAction(QIcon(":/image/Save.png"), tr("&Save..."), this); _save->setShortcuts(QKeySequence::Save); _save->setStatusTip(QString::fromUtf8("フォルダツリーをテキストに保存する")); _save->setEnabled(false); connect(_save, SIGNAL(triggered()), this, SLOT(saveFileList())); _print = new QAction(QIcon(":/image/Print.png"), tr("&Print..."), this); _print->setShortcuts(QKeySequence::Print); _print->setStatusTip(QString::fromUtf8("フォルダツリーを印刷する")); _print->setEnabled(false); connect(_print, SIGNAL(triggered()), this, SLOT(printFileList())); _settings = new QAction(QIcon(":/image/Settings.png"), tr("&Settings..."), this); _settings->setStatusTip(QString::fromUtf8("設定")); connect(_settings, SIGNAL(triggered()), this, SLOT(showSettingsDlg())); _info = new QAction(QIcon(":/image/Info.png"), tr("&about H.F.D...."), this); _info->setStatusTip(QString::fromUtf8("HyperFileDumperについて")); connect(_info, SIGNAL(triggered()), this, SLOT(showInfoDlg())); }
void soundKonverter::setupActions() { KStandardAction::quit( this, SLOT(close()), actionCollection() ); KStandardAction::preferences( this, SLOT(showConfigDialog()), actionCollection() ); KAction *logviewer = actionCollection()->addAction("logviewer"); logviewer->setText(i18n("View logs...")); logviewer->setIcon(KIcon("view-list-text")); connect( logviewer, SIGNAL(triggered()), this, SLOT(showLogViewer()) ); KAction *replaygainscanner = actionCollection()->addAction("replaygainscanner"); replaygainscanner->setText(i18n("Replay Gain tool...")); replaygainscanner->setIcon(KIcon("soundkonverter-replaygain")); connect( replaygainscanner, SIGNAL(triggered()), this, SLOT(showReplayGainScanner()) ); KAction *aboutplugins = actionCollection()->addAction("aboutplugins"); aboutplugins->setText(i18n("About plugins...")); aboutplugins->setIcon(KIcon("preferences-plugin")); connect( aboutplugins, SIGNAL(triggered()), this, SLOT(showAboutPlugins()) ); KAction *add_files = actionCollection()->addAction("add_files"); add_files->setText(i18n("Add files...")); add_files->setIcon(KIcon("audio-x-generic")); connect( add_files, SIGNAL(triggered()), m_view, SLOT(showFileDialog()) ); KAction *add_folder = actionCollection()->addAction("add_folder"); add_folder->setText(i18n("Add folder...")); add_folder->setIcon(KIcon("folder")); connect( add_folder, SIGNAL(triggered()), m_view, SLOT(showDirDialog()) ); KAction *add_audiocd = actionCollection()->addAction("add_audiocd"); add_audiocd->setText(i18n("Add CD tracks...")); add_audiocd->setIcon(KIcon("media-optical-audio")); connect( add_audiocd, SIGNAL(triggered()), m_view, SLOT(showCdDialog()) ); KAction *add_url = actionCollection()->addAction("add_url"); add_url->setText(i18n("Add url...")); add_url->setIcon(KIcon("network-workgroup")); connect( add_url, SIGNAL(triggered()), m_view, SLOT(showUrlDialog()) ); KAction *add_playlist = actionCollection()->addAction("add_playlist"); add_playlist->setText(i18n("Add playlist...")); add_playlist->setIcon(KIcon("view-media-playlist")); connect( add_playlist, SIGNAL(triggered()), m_view, SLOT(showPlaylistDialog()) ); KAction *load = actionCollection()->addAction("load"); load->setText(i18n("Load file list")); load->setIcon(KIcon("document-open")); connect( load, SIGNAL(triggered()), m_view, SLOT(loadFileList()) ); KAction *save = actionCollection()->addAction("save"); save->setText(i18n("Save file list")); save->setIcon(KIcon("document-save")); connect( save, SIGNAL(triggered()), m_view, SLOT(saveFileList()) ); actionCollection()->addAction("start", m_view->start()); actionCollection()->addAction("stop_menu", m_view->stopMenu()); }
soundKonverterView::soundKonverterView( Logger *_logger, Config *_config, CDManager *_cdManager, QWidget *parent ) : QWidget( parent ), config( _config ), logger( _logger ), cdManager( _cdManager ) { setAcceptDrops( true ); const int fontHeight = QFontMetrics(QApplication::font()).boundingRect("M").size().height(); // the grid for all widgets in the main window QGridLayout* gridLayout = new QGridLayout( this ); fileList = new FileList( logger, config, this ); gridLayout->addWidget( fileList, 1, 0 ); gridLayout->setRowStretch( 1, 1 ); connect( fileList, SIGNAL(fileCountChanged(int)), this, SLOT(fileCountChanged(int)) ); connect( fileList, SIGNAL(conversionStarted()), this, SLOT(conversionStarted()) ); connect( fileList, SIGNAL(conversionStopped(bool)), this, SLOT(conversionStopped(bool)) ); connect( fileList, SIGNAL(queueModeChanged(bool)), this, SLOT(queueModeChanged(bool)) ); connect( fileList, SIGNAL(showLog(int)), this, SIGNAL(showLog(int)) ); optionsLayer = new OptionsLayer( config, this ); fileList->setOptionsLayer( optionsLayer ); optionsLayer->hide(); gridLayout->addWidget( optionsLayer, 1, 0 ); connect( optionsLayer, SIGNAL(done(const KUrl::List&,ConversionOptions*,const QString&)), fileList, SLOT(addFiles(const KUrl::List&,ConversionOptions*,const QString&)) ); connect( optionsLayer, SIGNAL(saveFileList()), fileList, SLOT(save()) ); // add a horizontal box layout for the add combobutton to the grid QHBoxLayout *addBox = new QHBoxLayout(); addBox->setContentsMargins( 1, 0, 1, 0 ); // extra margin - determined by experiments gridLayout->addLayout( addBox, 3, 0 ); // create the combobutton for adding files to the file list cAdd = new ComboButton( this ); QFont font = cAdd->font(); //font.setWeight( QFont::DemiBold ); font.setPointSize( font.pointSize() + 3 ); cAdd->setFont( font ); cAdd->insertItem( KIcon("audio-x-generic"), i18n("Add files...") ); cAdd->insertItem( KIcon("folder"), i18n("Add folder...") ); cAdd->insertItem( KIcon("media-optical-audio"), i18n("Add CD tracks...") ); cAdd->insertItem( KIcon("network-workgroup"), i18n("Add url...") ); cAdd->insertItem( KIcon("view-media-playlist"), i18n("Add playlist...") ); cAdd->increaseHeight( 0.6*fontHeight ); addBox->addWidget( cAdd, 0, Qt::AlignVCenter ); connect( cAdd, SIGNAL(clicked(int)), this, SLOT(addClicked(int)) ); cAdd->setFocus(); addBox->addSpacing( fontHeight ); startAction = new KAction( KIcon("system-run"), i18n("Start"), this ); connect( startAction, SIGNAL(triggered()), fileList, SLOT(startConversion()) ); pStart = new KPushButton( KIcon("system-run"), i18n("Start"), this ); pStart->setFixedHeight( pStart->size().height() ); pStart->setEnabled( false ); startAction->setEnabled( false ); addBox->addWidget( pStart, 0, Qt::AlignVCenter ); connect( pStart, SIGNAL(clicked()), fileList, SLOT(startConversion()) ); stopActionMenu = new KActionMenu( KIcon("process-stop"), i18n("Stop"), this ); stopActionMenu->setDelayed( false ); killAction = new KAction( KIcon("flag-red"), i18n("Stop immediatelly"), this ); stopActionMenu->addAction( killAction ); connect( killAction, SIGNAL(triggered()), fileList, SLOT(killConversion()) ); stopAction = new KAction( KIcon("flag-yellow"), i18n("Stop after current conversions are completed"), this ); stopActionMenu->addAction( stopAction ); connect( stopAction, SIGNAL(triggered()), fileList, SLOT(stopConversion()) ); continueAction = new KAction( KIcon("flag-green"), i18n("Continue after current conversions are completed"), this ); stopActionMenu->addAction( continueAction ); connect( continueAction, SIGNAL(triggered()), fileList, SLOT(continueConversion()) ); queueModeChanged( true ); pStop = new KPushButton( KIcon("process-stop"), i18n("Stop"), this ); pStop->setFixedHeight( pStop->size().height() ); pStop->hide(); stopActionMenu->setEnabled( false ); pStop->setMenu( stopActionMenu->menu() ); addBox->addWidget( pStop, 0, Qt::AlignVCenter ); addBox->addSpacing( fontHeight ); progressIndicator = new ProgressIndicator( this, ProgressIndicator::Feature( ProgressIndicator::FeatureSpeed | ProgressIndicator::FeatureTime ) ); addBox->addWidget( progressIndicator, 0, Qt::AlignVCenter ); connect( progressIndicator, SIGNAL(progressChanged(const QString&)), this, SIGNAL(progressChanged(const QString&)) ); connect( fileList, SIGNAL(timeChanged(float)), progressIndicator, SLOT(timeChanged(float)) ); connect( fileList, SIGNAL(finished(bool)), progressIndicator, SLOT(finished(bool)) ); Convert *convert = new Convert( config, fileList, logger, this ); connect( fileList, SIGNAL(convertItem(FileListItem*)), convert, SLOT(add(FileListItem*)) ); connect( fileList, SIGNAL(killItem(FileListItem*)), convert, SLOT(kill(FileListItem*)) ); connect( fileList, SIGNAL(itemRemoved(FileListItem*)), convert, SLOT(itemRemoved(FileListItem*)) ); connect( convert, SIGNAL(finished(FileListItem*,FileListItem::ReturnCode,bool)), fileList, SLOT(itemFinished(FileListItem*,FileListItem::ReturnCode,bool)) ); connect( convert, SIGNAL(rippingFinished(const QString&)), fileList, SLOT(rippingFinished(const QString&)) ); connect( convert, SIGNAL(finishedProcess(int,bool,bool)), logger, SLOT(processCompleted(int,bool,bool)) ); connect( convert, SIGNAL(updateTime(float)), progressIndicator, SLOT(update(float)) ); connect( convert, SIGNAL(timeFinished(float)), progressIndicator, SLOT(timeFinished(float)) ); }
//only for convenience, once changed, save the file list automatically if you want. //But you have to emit the "changed" signal and connect it to the slot void FileListUtil::do_fileListChanged(const QStringList &list) { saveFileList(list); }