Ejemplo n.º 1
0
void TagEditOrCloneAction::run() {
	shared_ptr<ZLDialog> dialog = ZLDialogManager::Instance().createDialog(ZLResourceKey(resourceKeyName()));

	TagList tags;
	BooksUtil::collectTagsFromLibrary(tags);
	std::vector<std::string> names;
	for (TagList::const_iterator it = tags.begin(); it != tags.end(); ++it) {
		if (!it->isNull()) {
			names.push_back((*it)->fullName());
		}
	}
	TagNameEntry *tagNameEntry = new TagNameEntry(names, myTag->fullName());
	dialog->addOption(ZLResourceKey("name"), tagNameEntry);

	TagIncludeSubtagsEntry *includeSubtagsEntry = new TagIncludeSubtagsEntry();
	const Library &library = Library::Instance();
	if (library.hasSubtags(myTag)) {
		if (!library.hasBooks(myTag)) {
			includeSubtagsEntry->setActive(false);
		}
		dialog->addOption(ZLResourceKey("includeSubtags"), includeSubtagsEntry);
	}

	dialog->addButton(ZLDialogManager::OK_BUTTON, true);
	dialog->addButton(ZLDialogManager::CANCEL_BUTTON, false);

	if (dialog->run()) {
		dialog->acceptValues();
		onAccept(tagNameEntry->initialValue(), includeSubtagsEntry->initialState());
	}
}
Ejemplo n.º 2
0
CUsuarios::CUsuarios ( CData* _data, QWidget *_parent ) :
		QDialog ( _parent ),
		m_data ( _data ),
		m_model ( 0 ),
		m_delegate ( 0 )
{
	setupUi ( this );
	setAttribute ( Qt::WA_DeleteOnClose );

	connect ( this, SIGNAL ( accepted() ), this, SLOT ( onAccept() ) );

	m_model = new CUsuariosModel ( m_data );
	tableView->setModel ( m_model );

	m_delegate = new CUsuarioDelegate ( m_data, this );
	tableView->setItemDelegate ( m_delegate );

	QFontMetrics fontMetrics ( tableView->horizontalHeader()->font() );

	int width = fontMetrics.width ( tr ( " Esquema XX " ) );;
	int x = 0;
	for ( int i = 3; i < 5; ++i )
	{
		x = fontMetrics.width ( m_model->headerData ( i, Qt::Horizontal ).toString() );
		if ( x > width ) width = x;
	}

	for ( int i = 3; i < 5; ++i )
	{
		tableView->setColumnWidth ( i, width + 10 );
	}
}
Ejemplo n.º 3
0
void SettingsDialog::initUI()
{
	setWindowTitle("Choose Bundle Search Paths");

	QVBoxLayout* verticalLayoutOuter = new QVBoxLayout();
	QHBoxLayout* horizontalLayoutTop = new QHBoxLayout();
	QVBoxLayout* verticalLayoutTopRight = new QVBoxLayout();

	QPushButton* pushButtonAdd = new QPushButton( "+" );
	QPushButton* pushButtonRemove = new QPushButton( "-" );
	QDialogButtonBox* buttonBoxBottom = new QDialogButtonBox( QDialogButtonBox::Ok );;

	QSpacerItem* verticalSpacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );;

	m_OptionsWidget = new QListWidget();

	verticalLayoutOuter->addLayout( horizontalLayoutTop );
	verticalLayoutOuter->addWidget( buttonBoxBottom, 1, 0 );

	horizontalLayoutTop->addWidget( m_OptionsWidget );
	horizontalLayoutTop->addLayout( verticalLayoutTopRight );

	verticalLayoutTopRight->addWidget( pushButtonAdd, 0, 0 );
	verticalLayoutTopRight->addWidget( pushButtonRemove, 1, 0 );
	verticalLayoutTopRight->addSpacerItem( verticalSpacer );

	this->setLayout( verticalLayoutOuter );
	this->setModal( true );

	connect( buttonBoxBottom, SIGNAL(accepted()), this, SLOT( onAccept()) );
	connect( buttonBoxBottom, SIGNAL(rejected()), this, SLOT( reject()) );
	connect( pushButtonAdd,   SIGNAL(clicked()),  this, SLOT( onAddItemSlot()) );
	connect( pushButtonRemove,SIGNAL(clicked()),  this, SLOT( onRemoveSelectedItems()) );
}
Ejemplo n.º 4
0
void FileBrowser::loadCartridge(CartridgeMode mode, signed filterIndex) {
  cartridgeMode = mode;
  onChange = { &FileBrowser::onChangeCartridge, this };
  onActivate = { &FileBrowser::onAcceptCartridge, this };
  onAccept = { &FileBrowser::onAcceptCartridge, this };

  string defaultPath = config().path.rom == "" ? config().path.current.cartridge : config().path.rom;

  if(config().diskBrowser.useCommonDialogs == true) {
    audio.clear();
    QString qfilename = QFileDialog::getOpenFileName(0,
      windowTitle(), defaultPath, string(
        "SNES cartridges (*.sfc *.bs *.st *.gb *.sgb *.gbc", reader.extensionList, reader.compressionList, ");;",
        "All files (*)"
      )
    );
    string filename = qfilename.toUtf8().constData();
    if(filename != "") onAccept(filename);
    config().path.current.cartridge = nall::dir(filename);
    return;
  }

  setPath(defaultPath);
  setNameFilters(string()
  << "SNES cartridges (*.sfc" << reader.extensionList << reader.compressionList << ")\n"
  << "BS-X cartridges (*.bs" << reader.compressionList << ")\n"
  << "Sufami Turbo cartridges (*.st" << reader.compressionList << ")\n"
  << "Game Boy cartridges (*.gb *.sgb *.gbc" << reader.compressionList << ")\n"
  << "All files (*)"
  );
  previewFrame->show();
  filterBox->setCurrentIndex(filterIndex == -1 ? config().path.current.filter : filterIndex);
  showLoad();
}
Ejemplo n.º 5
0
int main(int argv,char **args)
{
	int ret,epfd,nfds,server_socket_fd,i,index;
	struct epoll_event events[256];
	int count;	

	server_socket_fd = server_start();	
	if(server_socket_fd<0)
	{
		return 0;
	}
	set_non_blocking(server_socket_fd);

	epfd = epoll_create(1024);
	set_non_blocking(epfd);
	epoll_add(epfd,server_socket_fd);

	struct http_request_r *r=NULL,*p=NULL;

        while(1)
        {
                nfds=epoll_wait(epfd,events,20,500);
                for(i=0;i<nfds;i++)
                {
                        if(events[i].data.fd==server_socket_fd)
                        {
				onAccept(epfd,events[i],&r);
			}
                        else if(events[i].events&EPOLLIN)
                        {
				onData(epfd,events[i],&r);
                        }
                }
        }
}
Ejemplo n.º 6
0
NewPersonDialog::NewPersonDialog(QWidget* a_parent) :
	QDialog(a_parent)
{
	m_dialog.setupUi(this);

	//Connect
	connect(m_dialog.m_button_box, SIGNAL(accepted()), SLOT(onAccept()));
}
Ejemplo n.º 7
0
qAnimationDlg::qAnimationDlg( std::vector<VideoStepItem>& videoSteps, ccGLWindow* view3d, QWidget* parent)
	: QDialog(parent)
	, Ui::AnimationDialog()
	, m_videoSteps(videoSteps)
	, m_view3d(view3d)
{
	setupUi(this);

	setWindowFlags(Qt::Tool/*Qt::Dialog | Qt::WindowStaysOnTopHint*/);

	for ( size_t i=0; i<m_videoSteps.size(); ++i )
	{
		cc2DViewportObject* viewport1 = m_videoSteps[i].interpolator.view1();

		stepSelectionList->addItem( viewport1->getName() );

		//check if the (1st) viewport has a duration in meta data (from a previous run)
		double duration_sec = 2.0;
		if (viewport1->hasMetaData(s_stepDurationKey))
		{
			duration_sec = viewport1->getMetaData(s_stepDurationKey).toDouble();
		}
		m_videoSteps[i].duration_sec = duration_sec;
	}

	//read persistent settings
	{
		QSettings settings;
		settings.beginGroup("qAnimation");
		QString defaultDir;
#ifdef _MSC_VER
		defaultDir = QApplication::applicationDirPath();
#else
		defaultDir = QDir::homePath();
#endif
		QString lastFilename = settings.value("filename", defaultDir + "/animation.mpg" ).toString();
#ifndef QFFMPEG_SUPPORT
		lastFilename = QFileInfo(lastFilename).absolutePath();
#endif
		outputFileLineEdit->setText( lastFilename );
		settings.endGroup();
	}

	connect ( fpsSpinBox,				SIGNAL( valueChanged(double) ),		this, SLOT( onFPSChanged(double) ) );
	connect ( totalTimeDoubleSpinBox,	SIGNAL( valueChanged(double) ),		this, SLOT( onTotalTimeChanged(double) ) );
	connect ( stepTimeDoubleSpinBox,	SIGNAL( valueChanged(double) ),		this, SLOT( onStepTimeChanged(double) ) );
	connect ( stepSelectionList,		SIGNAL( currentRowChanged(int) ),	this, SLOT( onCurrentStepChanged(int) ) );
	connect ( browseButton,				SIGNAL( clicked() ),				this, SLOT( onBrowseButtonClicked() ) );
	connect ( previewButton,			SIGNAL( clicked() ),				this, SLOT( preview() ) );
	connect ( renderButton,				SIGNAL( clicked() ),				this, SLOT( render() ) );
	connect ( buttonBox,				SIGNAL( accepted() ),				this, SLOT( onAccept() ) );

	stepSelectionList->setCurrentRow(0); //select the first one by default

	onCurrentStepChanged(getCurrentStepIndex());
	updateTotalDuration();
}
Ejemplo n.º 8
0
qAnimationDlg::qAnimationDlg(ccGLWindow* view3d, QWidget* parent)
	: QDialog(parent, Qt::Tool)
	, Ui::AnimationDialog()
	, m_view3d(view3d)
{
	setupUi(this);

	//restore previous settings
	{
		QSettings settings;
		settings.beginGroup("qAnimation");
		
		//last filename
		{
			QString defaultDir;
#ifdef _MSC_VER
			defaultDir = QApplication::applicationDirPath();
#else
			defaultDir = QDir::homePath();
#endif
			const QString defaultFileName( defaultDir + "/animation.mp4" );
			QString lastFilename = settings.value("filename", defaultFileName ).toString();
#ifndef QFFMPEG_SUPPORT
			lastFilename = QFileInfo(lastFilename).absolutePath();
#endif
			outputFileLineEdit->setText( lastFilename );
		}

		//other parameters
		{
			bool startPreviewFromSelectedStep = settings.value("previewFromSelected", previewFromSelectedCheckBox->isChecked()).toBool();
			bool loop = settings.value("loop", loopCheckBox->isChecked()).toBool();
			int frameRate = settings.value("frameRate", fpsSpinBox->value()).toInt();
			int superRes = settings.value("superRes", superResolutionSpinBox->value()).toInt();
			int bitRate = settings.value("bitRate", bitrateSpinBox->value()).toInt();

			previewFromSelectedCheckBox->setChecked(startPreviewFromSelectedStep);
			loopCheckBox->setChecked(loop);
			fpsSpinBox->setValue(frameRate);
			superResolutionSpinBox->setValue(superRes);
			bitrateSpinBox->setValue(bitRate);
		}
		
		settings.endGroup();
	}

	connect ( fpsSpinBox,				SIGNAL( valueChanged(int) ),		this, SLOT( onFPSChanged(int) ) );
	connect ( totalTimeDoubleSpinBox,	SIGNAL( valueChanged(double) ),		this, SLOT( onTotalTimeChanged(double) ) );
	connect ( stepTimeDoubleSpinBox,	SIGNAL( valueChanged(double) ),		this, SLOT( onStepTimeChanged(double) ) );
	connect ( loopCheckBox,				SIGNAL( toggled(bool) ),			this, SLOT( onLoopToggled(bool) ) );

	connect ( browseButton,				SIGNAL( clicked() ),				this, SLOT( onBrowseButtonClicked() ) );
	connect ( previewButton,			SIGNAL( clicked() ),				this, SLOT( preview() ) );
	connect ( renderButton,				SIGNAL( clicked() ),				this, SLOT( renderAnimation() ) );
	connect ( exportFramesPushButton,	SIGNAL( clicked() ),				this, SLOT( renderFrames() ) );
	connect ( buttonBox,				SIGNAL( accepted() ),				this, SLOT( onAccept() ) );
}
Ejemplo n.º 9
0
SimplePasswordWidget::SimplePasswordWidget(Account *account, SimplePasswordDialog *parent) :
		ui(new Ui::SimplePasswordWidget)
{
	ui->setupUi(this);
	ui->label->setText(ui->label->text().arg(account->id(), account->protocol()->id()));
	connect(this, SIGNAL(accepted()), this, SLOT(onAccept()));
	connect(this, SIGNAL(rejected()), this, SLOT(onReject()));
	m_account = account;
	m_parent = parent;
}
Ejemplo n.º 10
0
	//-----------------------------------------------------------------------------
	void GameNetUdpPacketManager::handleNetEvent(INetUdpEvent* netEvent)
	{
		if ( netEvent )
		{
			if ( netEvent->getType() == NET_RECV  )
			{
				NetUdpEventRecv* netUdpEventRecv = dynamic_cast<NetUdpEventRecv*>(netEvent);
				if ( netUdpEventRecv )
				{
					//if ( checkRecvPacketValid(netEvent->getHandle(),netEvent->getID(),
					//        (GameNetPacketHeader*)NetUdpEventRecv->getData(),NetUdpEventRecv->getDataSize()) )
					onRecv(netUdpEventRecv);
				}
			}
			else if (netEvent->getType() == NET_ACCEPT)
			{
				NetUdpEventAccept* netUdpEventAccept = dynamic_cast<NetUdpEventAccept*>(netEvent);
				if ( netUdpEventAccept )
				{
					onAccept(netUdpEventAccept);
				}
			}
			else if (netEvent->getType() == NET_CONNECT)
			{
				NetUdpEventConnect* netUdpEventConnect = dynamic_cast<NetUdpEventConnect*>(netEvent);
				if ( netUdpEventConnect )
				{
					onConnected(netUdpEventConnect);
				}
			}
			else if (netEvent->getType() == NET_CLOSE)
			{
				NetUdpEventClose* netUdpEventClose = dynamic_cast<NetUdpEventClose*>(netEvent);
				if ( netUdpEventClose )
				{
					onClose(netUdpEventClose);
				}
			}
			else if (netEvent->getType() == NET_ERR)
			{
				NetUdpEventErr* netUdpEventError = dynamic_cast<NetUdpEventErr*>(netEvent);
				if ( netUdpEventError )
				{
					onError(netUdpEventError);
				}
			}

			if ( netEvent->isNeedGc() )
			{
				freeEvent( netEvent );
			}
		}
	}
Ejemplo n.º 11
0
BOOL QueryConnectionDialog::onCommand(UINT controlID, UINT notificationID)
{
  switch (controlID) {
  case IDC_ACCEPT_BUTTON:
    onAccept();
    break;
  case IDC_REJECT_BUTTON:
    onReject();
    break;
  }
  return TRUE;
}
Ejemplo n.º 12
0
CAreas::CAreas ( CData* _data, CMainWindow* _form ) :
		QDialog ( _form ),
		m_model ( 0 )
{
	setupUi ( this );
	setAttribute ( Qt::WA_DeleteOnClose );

	m_model = new CAreasModel ( _data );
	tableView->setModel ( m_model );

	connect ( this, SIGNAL ( accepted() ), this, SLOT ( onAccept() ) );
	connect ( this, SIGNAL ( accepted() ), _form, SLOT ( refreshAreas() ) );
}
Ejemplo n.º 13
0
void FileBrowser::chooseFile() {
  if(config().diskBrowser.useCommonDialogs == true) {
    audio.clear();
    QString qfilename = QFileDialog::getOpenFileName(0,
      windowTitle(), fileSystemModel->rootPath(), "All Files (*)"
    );
    string filename = qfilename.toUtf8().constData();
    if(filename != "") onAccept(filename);
    return;
  }

  showLoad();
}
Ejemplo n.º 14
0
LoadWindow::LoadWindow(QWidget *parent, const QStringList &tierList, const QString &name) :
    QDialog(parent),
    ui(new Ui::LoadWindow)
{
    ui->setupUi(this);

    holder.load();

    LoadLine *array[] = {ui->line1, ui->line2, ui->line3, ui->line4, ui->line5, ui->line6};
    memcpy(lines, array, sizeof(array));

    lines[0]->setUi(ui->name1, ui->gen1, ui->tier1, ui->browser1, tierList);
    lines[1]->setUi(ui->name2, ui->gen2, ui->tier2, ui->browser2, tierList);
    lines[2]->setUi(ui->name3, ui->gen3, ui->tier3, ui->browser3, tierList);
    lines[3]->setUi(ui->name4, ui->gen4, ui->tier4, ui->browser4, tierList);
    lines[4]->setUi(ui->name5, ui->gen5, ui->tier5, ui->browser5, tierList);
    lines[5]->setUi(ui->name6, ui->gen6, ui->tier6, ui->browser6, tierList);

    for (int i = 0; i < 6; i++) {
        if (i >= holder.count()) {
            lines[i]->setChecked(false);
        } else {
            lines[i]->setTeam(holder.team(i));
            lines[i]->setChecked(true);
        }
    }

    /* Hide profile & color from TeamBuilder, since there's a few bugs and you can edit it all in TeamBuilder anyway... */
    if (name == "") {
        ui->profileList->hide();
        ui->colorButton->hide();
    }

    /* To reduce excessive code, this will make the color the same color as your current profile by default */
    on_profileList_currentIndexChanged(name);

    QSettings s;

    QStringList profiles = holder.profile().getProfileList(s.value("Profile/Path").toString());
    QComboBox *profileList = ui->profileList;
    profileList->blockSignals(true);
    profileList->addItems(profiles);
    profileList->blockSignals(false);
    for (int i = 0; i < profileList->count(); ++i) {
        if (profileList->itemText(i) == name)
            profileList->setCurrentIndex(i);
    }

    connect(this, SIGNAL(accepted()), SLOT(onAccept()));
}
Ejemplo n.º 15
0
void FileBrowser::chooseFolder() {
  if(config().diskBrowser.useCommonDialogs == true) {
    audio.clear();
    QString qfilename = QFileDialog::getExistingDirectory(0,
      windowTitle(), config().path.current.folder,
      QFileDialog::ShowDirsOnly
    );
    string filename = qfilename.toUtf8().constData();
    if(filename != "") onAccept(filename);
    return;
  }

  previewFrame->hide();
  showFolder();
}
Ejemplo n.º 16
0
void QueryConnectionDialog::onTimer()
{
  if (m_timeout == 0) {
    KillTimer(m_ctrlThis.getWindow(), 0);

    if (m_acceptByDefault) {
      onAccept();
    } else {
      onReject();
    }
  } else {
    m_timeout--;

    updateTimeoutLabel();
  }
}
Ejemplo n.º 17
0
void TcpServer::onAccept(struct ev_loop *loop, CustomIO *watcher, int revents)
{
	sockaddr_in client_addr;
#ifdef WIN32
	int
#else
	socklen_t
#endif
	client_len = sizeof(client_addr);

	// Accept client request
#ifdef WIN32
	SOCKET
#else
	int
#endif
	client_sd = accept(FD_TO_HANDLE(watcher->io.fd), (sockaddr *)&client_addr, &client_len);

	if (client_sd < 0)
	{
		perror("accept error");
		return;
	}
	
	// set non-blocking
#ifdef WIN32
    unsigned long iMode = 1;
    ioctlsocket(client_sd, FIONBIO, &iMode);
#else
	fcntl(client_sd, F_SETFL, fcntl(client_sd, F_GETFL, 0) | O_NONBLOCK);
#endif
	
	printf("Successfully connected with client fd %d.\n", HANDLE_TO_FD(client_sd));

	CustomClientIO *w_client = new CustomClientIO;
	w_client->pThis = this;
	w_client->pClient = getSocket();
	w_client->pClient->m_iSocket = client_sd;
	w_client->pClient->m_pOtherWatcher = &w_client->io;
	
	// Initialize and start watcher to read client requests
	ev_io_init(&w_client->io, &TcpServer::onReadWriteHelper, HANDLE_TO_FD(client_sd), EV_READ | EV_WRITE);
	//ev_io_set(&w_client->io, client_sd, EV_READ);
	ev_io_start(loop, &w_client->io);
	
	onAccept(w_client->pClient);
}
Ejemplo n.º 18
0
void StormService::update(int64_t ms) {
	StormListener::Packet* packet;
	while (m_listener->m_queue.pop_front(packet, ms)) {
		switch (packet->type) {
			case StormListener::PacketType_Accept:
				onAccept(packet->conn);
				break;
			case StormListener::PacketType_Close:
				onClose(packet->conn, packet->closeType);
				break;
			case StormListener::PacketType_Packet:
				onRequest(packet->conn, packet->data.c_str(), packet->data.size());
				break;
		}
		delete packet;
	}
}
Ejemplo n.º 19
0
void Acceptor::onEvent(Epoller* p,uint32_t events)
{

    struct sockaddr_in addr;
    socklen_t socksize = sizeof(sockaddr_in);

    int sockfd = TcpSocket::accept(ev._fd,(sockaddr*)&addr, socksize);

    if(sockfd < 0)
    {
        WARN("Accept a bad socket:"<<sockfd);
        return;
    }

    onAccept(sockfd);

    TRACE_FMG("accept a new connection: sockfd:%u",sockfd);
}
Ejemplo n.º 20
0
    virtual bool onAcceptable(ErrorCode* ec)
    {
        ErrorCode tmpec;

        for (;;)
        {
            tmpec.reset();

            struct sockaddr_storage ss;
            socklen_t socklen = sizeof(ss);
            int new_fd = ::accept(fd(), (struct sockaddr*)&ss, &socklen);
            if (-1 == new_fd)
                break;

            if (0 == socklen)
            {
                SocketHelper::closeSocket(new_fd, &tmpec);
                continue;
            }

            SockAddr addr((struct sockaddr*)&ss, socklen);

            if (addr.getType() == AF_UNIX)
            {
                if (!checkUnixDomain(addr))
                {
                    SocketHelper::closeSocket(new_fd, &tmpec);
                    continue;
                }
            }

            try
            {
            	onAccept(new_fd, addr);
            }
            catch (...)
            {
            }
        }
        return true;
    }
Ejemplo n.º 21
0
CSchemas::CSchemas ( CData* _data, QWidget * _parent ) :
		QDialog ( _parent ),
		m_data ( _data ),
		m_model ( 0 )
{
	setupUi ( this );
	setAttribute ( Qt::WA_DeleteOnClose );

	connect ( this, SIGNAL ( accepted() ), this, SLOT ( onAccept() ) );

	connect ( slRed, SIGNAL ( valueChanged ( int ) ), this, SLOT ( onsliderMoved() ) );
	connect ( slGreen, SIGNAL ( valueChanged ( int ) ), this, SLOT ( onsliderMoved() ) );
	connect ( slBlue, SIGNAL ( valueChanged ( int ) ), this, SLOT ( onsliderMoved() ) );

	m_model = new CSchemasModel ( m_data );
	tableView->setModel ( m_model );
	tableView->setColumnHidden ( 2, true );

	lblCor->setBackgroundRole ( QPalette::Window );
	onsliderMoved();
}
Ejemplo n.º 22
0
void serve(int sockfd)
{
    int clfd,status;
    pid_t pid;
    for(;;){
        clfd = accept(sockfd,NULL,NULL);
        printf("accept!\n");
        if(clfd < 0){
            printf("uuwebserver: accept error: %s",strerror(errno));
            exit(EXIT_ERROR);
        }
        if( (pid = fork()) < 0){
            printf("uuwebserver: fork error: %s",strerror(errno));
        }
        else if( 0 == pid){
            onAccept(clfd);
            close(clfd) ;
        }
        else{
            close(clfd);
            waitpid(pid,&status,0);
        }
    }
}
Ejemplo n.º 23
0
void FileBrowser::accept(const string &path) {
  if(onAccept) onAccept(path);
}
Ejemplo n.º 24
0
void ZLTextOptionEntry::onAccept(const char *value) {
	onAccept((value != 0) ? std::string(value) : std::string());
}
Ejemplo n.º 25
0
OrganizeCollectionDialog::OrganizeCollectionDialog( const Meta::TrackList &tracks,
                                                    const QStringList &folders,
                                                    const QString &targetExtension,
                                                    QWidget *parent,
                                                    const char *name,
                                                    bool modal,
                                                    const QString &caption,
                                                    QFlags<KDialog::ButtonCode> buttonMask )
    : KDialog( parent )
    , ui( new Ui::OrganizeCollectionDialogBase )
    , m_detailed( true )
    , m_schemeModified( false )
    , m_conflict( false )
{
    Q_UNUSED( name )

    setCaption( caption );
    setModal( modal );
    setButtons( buttonMask );
    showButtonSeparator( true );
    m_targetFileExtension = targetExtension;

    if( tracks.size() > 0 )
        m_allTracks = tracks;

    KVBox *mainVBox = new KVBox( this );
    setMainWidget( mainVBox );
    QWidget *mainContainer = new QWidget( mainVBox );

    ui->setupUi( mainContainer );

    m_trackOrganizer = new TrackOrganizer( m_allTracks, this );

    ui->folderCombo->insertItems( 0, folders );
    if( ui->folderCombo->contains( AmarokConfig::organizeDirectory() ) )
        ui->folderCombo->setCurrentItem( AmarokConfig::organizeDirectory() );
    else
        ui->folderCombo->setCurrentIndex( 0 ); //TODO possible bug: assumes folder list is not empty.

    ui->overwriteCheck->setChecked( AmarokConfig::overwriteFiles() );

    ui->optionsWidget->setReplaceSpaces( AmarokConfig::replaceSpace() );
    ui->optionsWidget->setPostfixThe( AmarokConfig::ignoreThe() );
    ui->optionsWidget->setVfatCompatible( AmarokConfig::vfatCompatible() );
    ui->optionsWidget->setAsciiOnly( AmarokConfig::asciiOnly() );
    ui->optionsWidget->setRegexpText( AmarokConfig::replacementRegexp() );
    ui->optionsWidget->setReplaceText( AmarokConfig::replacementString() );

    ui->previewTableWidget->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
    ui->conflictLabel->setText("");
    QPalette p = ui->conflictLabel->palette();
    KColorScheme::adjustForeground( p, KColorScheme::NegativeText ); // TODO this isn't working, the color is still normal
    ui->conflictLabel->setPalette( p );
    ui->previewTableWidget->sortItems( 0, Qt::AscendingOrder );

    // only show the options when the Options button is checked
    connect( ui->optionsButton, SIGNAL(toggled(bool)), ui->organizeCollectionWidget, SLOT(setVisible(bool)) );
    connect( ui->optionsButton, SIGNAL(toggled(bool)), ui->optionsWidget, SLOT(setVisible(bool)) );
    ui->organizeCollectionWidget->hide();
    ui->optionsWidget->hide();

    connect( ui->folderCombo, SIGNAL(currentIndexChanged(QString)), SLOT(slotUpdatePreview()) );
    connect( ui->organizeCollectionWidget, SIGNAL(schemeChanged()), SLOT(slotUpdatePreview()) );
    connect( ui->optionsWidget, SIGNAL(optionsChanged()), SLOT(slotUpdatePreview()));
    // to show the conflict error
    connect( ui->overwriteCheck, SIGNAL(stateChanged(int)), SLOT(slotOverwriteModeChanged()) );

    connect( this, SIGNAL(finished(int)), ui->organizeCollectionWidget, SLOT(slotSaveFormatList()) );
    connect( this, SIGNAL(accepted()), ui->organizeCollectionWidget, SLOT(onAccept()) );
    connect( this, SIGNAL(accepted()), SLOT(slotDialogAccepted()) );
    connect( ui->folderCombo, SIGNAL(currentIndexChanged(QString)),
             SLOT(slotEnableOk(QString)) );

    slotEnableOk( ui->folderCombo->currentText() );
    restoreDialogSize( Amarok::config( "OrganizeCollectionDialog" ) );

    QTimer::singleShot( 0, this, SLOT(slotUpdatePreview()) );
}
Ejemplo n.º 26
0
void Connection::internOnAccept() {
	onAccept();
}
CustomColorDialog::CustomColorDialog(QWidget *parent) : QFrame(parent )
{

    setFrameStyle(QFrame::NoFrame);
    setFrameShape(QFrame::StyledPanel);
    setFrameShadow(QFrame::Sunken);

    QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect;
    dropShadowEffect->setBlurRadius(6);
    dropShadowEffect->setOffset(2, 2);
    setGraphicsEffect(dropShadowEffect);
    setAutoFillBackground(true);

    m_hueControl = new HueControl(this);
    m_colorBox = new ColorBox(this);

    QWidget *colorFrameWidget = new QWidget(this);
    QVBoxLayout* vBox = new QVBoxLayout(colorFrameWidget);
    colorFrameWidget->setLayout(vBox);
    vBox->setSpacing(0);
    vBox->setMargin(0);
    vBox->setContentsMargins(0,5,0,28);

    m_beforeColorWidget = new QFrame(colorFrameWidget);
    m_beforeColorWidget->setFixedSize(30, 18);
    m_beforeColorWidget->setAutoFillBackground(true);

    m_currentColorWidget = new QFrame(colorFrameWidget);
    m_currentColorWidget->setFixedSize(30, 18);
    m_currentColorWidget->setAutoFillBackground(true);

    vBox->addWidget(m_beforeColorWidget);
    vBox->addWidget(m_currentColorWidget);


    m_rSpinBox = new QDoubleSpinBox(this);
    m_gSpinBox = new QDoubleSpinBox(this);
    m_bSpinBox = new QDoubleSpinBox(this);
    m_alphaSpinBox = new QDoubleSpinBox(this);

    QGridLayout *gridLayout = new QGridLayout(this);
    gridLayout->setSpacing(4);
    gridLayout->setVerticalSpacing(4);
    gridLayout->setMargin(4);
    setLayout(gridLayout);

    gridLayout->addWidget(m_colorBox, 0, 0, 4, 1);
    gridLayout->addWidget(m_hueControl, 0, 1, 4, 1);

    gridLayout->addWidget(colorFrameWidget, 0, 2, 2, 1);

    gridLayout->addWidget(new QLabel("R", this), 0, 3, 1, 1);
    gridLayout->addWidget(new QLabel("G", this), 1, 3, 1, 1);
    gridLayout->addWidget(new QLabel("B", this), 2, 3, 1, 1);
    gridLayout->addWidget(new QLabel("A", this), 3, 3, 1, 1);

    gridLayout->addWidget(m_rSpinBox, 0, 4, 1, 1);
    gridLayout->addWidget(m_gSpinBox, 1, 4, 1, 1);
    gridLayout->addWidget(m_bSpinBox, 2, 4, 1, 1);
    gridLayout->addWidget(m_alphaSpinBox, 3, 4, 1, 1);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(this);

    QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
    QPushButton *applyButton = buttonBox->addButton(QDialogButtonBox::Apply);

    gridLayout->addWidget(buttonBox, 4, 0, 1, 2);

    resize(sizeHint());

    connect(m_colorBox, SIGNAL(colorChanged()), this, SLOT(onColorBoxChanged()));
    connect(m_alphaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
    connect(m_rSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
    connect(m_gSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
    connect(m_bSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
    connect(m_hueControl, SIGNAL(hueChanged(int)), this, SLOT(onHueChanged(int)));

    connect(applyButton, SIGNAL(pressed()), this, SLOT(onAccept()));
    connect(cancelButton, SIGNAL(pressed()), this, SIGNAL(rejected()));

    m_alphaSpinBox->setMaximum(1);
    m_rSpinBox->setMaximum(1);
    m_gSpinBox->setMaximum(1);
    m_bSpinBox->setMaximum(1);
    m_alphaSpinBox->setSingleStep(0.1);
    m_rSpinBox->setSingleStep(0.1);
    m_gSpinBox->setSingleStep(0.1);
    m_bSpinBox->setSingleStep(0.1);

    m_blockUpdate = false;
}