Example #1
0
//---------------------------------------------------------------------------
TableDialog::TableDialog(TableModel *tableModel, QWidget *parent) : 
  QDialog(parent) {
  
  // Setup the dialog.

  setupUi(this);
  this->tableModel = tableModel;

  // Setup the table view.

  tableView->setModel(tableModel);
  tableView->hideColumn(3);
  selectModel = tableView->selectionModel();

  QHeaderView *header = tableView->header();
  int len = header->length();

  header->resizeSection(0, 4*len/10);
  header->resizeSection(1, 6*len/10);

  // ...

  connect(upButton, SIGNAL(clicked()), this, SLOT(moveUp()));
  connect(downButton, SIGNAL(clicked()), this, SLOT(moveDown()));
  connect(enableButton, SIGNAL(clicked()), this, SLOT(enable()));
  connect(disableButton, SIGNAL(clicked()), this, SLOT(disable()));
  connect(installButton, SIGNAL(clicked()), this, SLOT(chooseDir()));
}
Example #2
0
/* TODO... finish this function as described below
 * move bugs 
 * if they move onto food, feed them
 * if they move onto another bug, no big deal.  Two bugs
 * can be in the same square.  Let's say bug#2 and bug #6 are in the same
 * square.  Well, both bugs are still in the bug_list, so they
 * will still be able to move next time step.
 * Since the world[][] array can only hold either a 2 or a 6, we'll just
 * put one of them there.  The easiest thing to do is just put which
 * ever bug moves into the square first into the square.  When the next
 * bug moves into the square, update his x and y (in bug_list) so that
 * he is in the square, leave the other bug alone (i.e., it's also in
 * the same square) and then set world[x][y] = 6 (the bug # of the second
 * bug).  No harm done.  The graphics will draw only the second bug
 * but who cares.  The next time step they'll move into different squares
 * (probably) and no one will notice.
 * NOTE: only the first bug to move into the square gets to eat the food
 * there.
 */
void moveBugs(void) {
    int total_age = 0;
    int total_gen = 0;

    /* update each bug in turn (but don't kill them) */
    for (int k = 0; k < bug_list.size(); ++k) {
        /* Clear the current square if we are the only one here.
         */
        if (world[bug_list[k].x][bug_list[k].y] ==  k) {
            world[bug_list[k].x][bug_list[k].y] = EMPTY;
        }
        /* Update bug position. */
        bug_list[k].x = newX(bug_list[k].x, bug_list[k].dir);
        bug_list[k].y = newY(bug_list[k].y, bug_list[k].dir);
        /* Bug eating behavior. */
        if (world[bug_list[k].x][bug_list[k].y] == FOOD) {
            bug_list[k].health += EAT_HEALTH;
        }
        /* Put the bug in the new spot. */
        world[bug_list[k].x][bug_list[k].y] = k;
        /* Bug movement health cost. */
        bug_list[k].health -= MOVE_HEALTH;
        /* Bug turn based on genes. */
        bug_list[k].dir = (bug_list[k].dir+chooseDir(bug_list[k].genes))%8;
        /* Bug statistics. */
        bug_list[k].age += 1;

        total_age += bug_list[k].age;
        total_gen += bug_list[k].generation;
    }
    average_age = total_age / bug_list.size();
    average_generation = total_gen / bug_list.size();
}
/*!
 \brief

*/
void SettingsDialog::setOutPutDir() {

    QString dir = chooseDir();
    if (!dir.isEmpty()) {
        outPutPath->setText(dir);
    }

}
Example #4
0
void TagEditor::createActions(){

    connect(LoadScriptButton,SIGNAL(clicked()),this,SLOT(loadScript()));
    connect(SaveScriptButton,SIGNAL(clicked()),this,SLOT(saveScript()));
    connect(RunScriptButton,SIGNAL(clicked()),this, SLOT(runScript()));

    QAction* searchOnlineAction = new QAction(tr("Search for selected file/album in online musicdatabases..."), this);
    searchOnlineAction->setShortcut(tr("Ctrl+S"));
    connect(searchOnlineAction, SIGNAL(triggered()), this, SLOT(searchOnline()));
    QAction* searchForFilesAction = new QAction(tr("Search for files to add to workspace..."), this);
    //searchForFilesAction->setShortcut(tr("Ctrl+S"));
    connect(searchForFilesAction, SIGNAL(triggered()), this, SLOT(searchAndAddFiles()));

    TreeView->setContextMenuPolicy(Qt::ActionsContextMenu);
    TreeView->addAction(searchOnlineAction);
    TreeView->addAction(searchForFilesAction);


    connect( TreeView, SIGNAL( expanded( const QModelIndex & )  ), this, SLOT( resizeColumn() ) );
    connect( TreeView, SIGNAL( collapsed( const QModelIndex & )  ), this, SLOT( resizeColumn() ) );
    //connect( TreeWidget_, SIGNAL( currentRowChanged( int )  ), this, SLOT( showTagInfo(int) ) );
    connect( TreeWidget_, SIGNAL( itemSelectionChanged() ), this, SLOT( showTagInfo() ) );
    connect( AddButton, SIGNAL( clicked()  ), this, SLOT(addFiles() ) );
    connect( RemoveButton, SIGNAL( clicked()  ), this, SLOT(removeFiles() ) );
    connect( ClearButton, SIGNAL( clicked()  ), this, SLOT(removeAllFiles() ) );
    connect( SaveButton, SIGNAL( clicked()  ), this, SLOT(saveTag() ) );
    connect( ChooseDirButton, SIGNAL( clicked()  ), this, SLOT(chooseDir() ) );

    connect( actionSettings, SIGNAL( triggered() ), this, SLOT( showSettings() ) );
    connect( actionRewriteTag, SIGNAL( triggered() ), this, SLOT( rewriteTag() ) );
    connect( actionRenameFiles, SIGNAL( triggered() ), this, SLOT( renameFiles() ) );
    connect( actionReplaceTags, SIGNAL( triggered() ), this, SLOT( replaceTags() ) );
    connect( actionSerialize, SIGNAL( triggered() ), this, SLOT( serialize() ) );
    connect( actionClearTags, SIGNAL( triggered() ), this, SLOT( clearTags() ) );
    //connect( actionRemoveFrames, SIGNAL( triggered() ), this, SLOT( removeFrames() ) );
    //styles

    QSignalMapper *styleMapper = new QSignalMapper(this);
    QStringList styles = QStyleFactory::keys();
    for(int i=0;i<styles.size();i++){
        QAction *a = new QAction(styles[i],menuStyle);
        a->setCheckable(true);
        connect(a, SIGNAL(triggered()), styleMapper, SLOT(map()));
        styleMapper->setMapping(a, styles[i]);
        menuStyle->addAction(a);
    }
    menuStyle->addSeparator();
    QAction *actionCustomStyleSheet = new QAction("Custom...",menuStyle);
    actionCustomStyleSheet->setCheckable(true);
    connect(actionCustomStyleSheet, SIGNAL(triggered()), this, SLOT(openStyleSheet()));
    menuStyle->addAction( actionCustomStyleSheet );
    connect(styleMapper, SIGNAL(mapped(const QString &)), this, SLOT(setGUIStyle(const QString &)));

}
Example #5
0
ExporterConfig &ExporterConfig::getInstance (void)
{
	static ExporterConfig *config = new ExporterConfig;

	if (config->rootDirectory.empty ())
	{
		char rootDir[MAX_PATH] = { 0 };
		char shareDir[MAX_PATH] = { 0 };
		if (chooseDir (::GetActiveWindow(), "选择资源根目录:", rootDir))
		{
			if (chooseDir (::GetActiveWindow(), "选择共享目录:", shareDir))
			{
				config->rootDirectory = rootDir;
				config->shareDirectory = shareDir;
				config->save ();
			}
		}
	}

	return *config;
}
Example #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    fbp_(new FbpClient())
{
    ui->setupUi(this);

#ifndef BRANDING
    ui->branding->hide();
#else
    // Search for BRANDING_LOGO
    QString brandingLogo( BRANDING_LOGO );
    QString prevDir("../");
    for(int i = 0; i < 6; ++i)
    {
        if( QFile::exists(prevDir.repeated(i) + brandingLogo) )
        {
            brandingLogo.prepend(prevDir.repeated(i));
        }
    }
    QPixmap logo(brandingLogo);
    ui->branding->setPixmap(logo);
#ifdef BRANDING_AUTOACCEPT
    ui->autoDownload->setChecked(true);
#endif
#ifdef BRANDING_WINDOW_TITLE
    setWindowTitle(BRANDING_WINDOW_TITLE);
#endif
#endif

    ui->files->setColumnWidth( 0, 30 );
    ui->files->setColumnWidth( 1, 250 );
    ui->files->setColumnWidth( 2, 250 );

    ui->downloadDir->setText( QDir::homePath() );
    connect( ui->chooseDir, SIGNAL(             clicked()                ),
             this,          SLOT(             chooseDir()                ) );
    connect( fbp_,          SIGNAL(           fileAdded(int,QString,int) ),
             this,          SLOT(             fileAdded(int,QString,int) ) );
    connect( fbp_,          SIGNAL(         fileRemoved(int)             ),
             this,          SLOT(           fileRemoved(int)             ) );
    connect( fbp_,          SIGNAL( fileProgressChanged(int,int)         ),
             this,          SLOT(   fileProgressChanged(int,int)         ) );
    connect( fbp_,          SIGNAL(fileOverwriteWarning(int, QString)    ),
             this,          SLOT(  fileOverwriteWarning(int, QString)    ) );
    connect( fbp_,          SIGNAL(    downloadFinished(int, QString)    ),
             this,          SLOT(      downloadFinished(int, QString)    ) );

    fbp_->startListening();
}
InitSeafileDialog::InitSeafileDialog(QWidget *parent)
    : QDialog(parent)
{
    setupUi(this);

    setWindowTitle(tr("Seafile Initialzation"));
    setWindowIcon(QIcon(":/images/seafile.png"));

    connect(mChooseDirBtn, SIGNAL(clicked()), this, SLOT(chooseDir()));
    connect(mOkBtn, SIGNAL(clicked()), this, SLOT(onOkClicked()));
    connect(mCancelBtn, SIGNAL(clicked()), this, SLOT(onCancelClicked()));

    mLogo->setPixmap(QPixmap(":/images/seafile-32.png"));
    mDirectory->setText(getInitialPath());

    const QRect screen = QApplication::desktop()->screenGeometry();
    move(screen.center() - this->rect().center());
}
InitSeafileDialog::InitSeafileDialog(QWidget *parent)
    : QDialog(parent)
{
    setupUi(this);

    setWindowTitle(tr("%1 Initialization").arg(getBrand()));
    setWindowIcon(QIcon(":/images/seafile.png"));
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    connect(mChooseDirBtn, SIGNAL(clicked()), this, SLOT(chooseDir()));
    connect(mOkBtn, SIGNAL(clicked()), this, SLOT(onOkClicked()));
    connect(mCancelBtn, SIGNAL(clicked()), this, SLOT(onCancelClicked()));

    mTitle->setStyleSheet("QLabel { color : #0099EE; }"); //disk42
    mLogo->setPixmap(QPixmap(":/images/seafile-32.png"));
    mDirectory->setText(getInitialPath());

    const QRect screen = QApplication::desktop()->screenGeometry();
    move(screen.center() - this->rect().center());
}
//--------------------------------------------------------------
void imageLoader::keyPressed  (int key){
   // cout << key << endl;
    switch(key){
        case (32):
            // next image with space bar
            if(images.size() > 0){
                anim = false;
                img01++;
                img01%=images.size();
                img02++;
                img02%=images.size();
                alpha01 = 255;
                alpha02 =0;
            }
            break;
        case (98):
            // back one image if 'b' is pressed
            if(images.size() > 0){
                anim = false;
                img01--;
                img01%=images.size();
                img02--;
                img02%=images.size();
                alpha01 = 255;
                alpha02 =0;
            }
            break;
        case (66):
            break;
        case (102):
            //fullscreen toggle if 'f' is pressed
            ofToggleFullscreen() ;
            break;
        case (70):
            //fullscreen toggle if 'f' is pressed CAPS
            ofToggleFullscreen() ;
            break;
        case (111):
            //open folder command if 'o' is pressed
            fScreen();
            chooseDir();
            break;
        case (79):
            //open folder command if 'o' is pressed CAPS
            fScreen();
            chooseDir();
            break;
        case(104):
            //show help info if 'h' is pressed
            if (help)
                help = false;
            else
                help = true;
            break;
        case(72):
            //show help info if 'h' is pressed CAPS
            showHelp();
            break;
    }

}