Beispiel #1
0
void cmap_array_widget::reload()
{

    while ( this->inside_widget->entries.count() > 0 )
    {
        Cmap_button* b = this->inside_widget->entries.takeAt(0);
        delete b;
    }

    CInside_widget* iw = (CInside_widget*) this->scrollView_insW->takeWidget();
    delete iw;
    this->inside_widget = new CInside_widget();
    this->scrollView_insW->setWidget( this->inside_widget );

    QDir target_folder( this->projectPath + "/maps/");
    QStringList list = target_folder.entryList( QDir::Files | QDir::NoDotAndDotDot, QDir::Name );
    QString str;

//    this->inside_widget->entries.clear();
    this->inside_widget->entries.append( new Cmap_button( tr( "Open Any .." ), "0", this->inside_widget ) );
    this->inside_widget->entries[0]->icon = QImage( ":/resources/img/open_map_128.png" );
    QObject::connect( this->inside_widget->entries[0], SIGNAL(clicked()),
                      this, SLOT(openManual()) );
    QObject::connect( this->btnZoom64, SIGNAL(clicked()),
                      this->inside_widget->entries[ 0 ], SLOT(scale_icon_to_64()));
    QObject::connect( this->btnZoom128, SIGNAL(clicked()),
                      this->inside_widget->entries[ 0 ], SLOT(scale_icon_to_128()));
    QObject::connect( this->btnZoom256, SIGNAL(clicked()),
                      this->inside_widget->entries[ 0 ], SLOT(scale_icon_to_256()));


    //first we fetch all the *.map files into this->scroll_widget->entryFilenames
    for ( int i = 0; i < list.count(); i++ )
    {
        str = list[ i ];
        if ( str.right( 4 ) == ".map" )
        {
            Cmap_button* mb = new Cmap_button( str, this->projectPath + "/maps/" + str, this->inside_widget );
            mb->show();
            this->inside_widget->entries.append( mb );
//            this->inside_widget->entries[ this->inside_widget->entries.count() -1 ]->setIcon( QIcon( this->projectPath + "/maps/" + str + ".preview" ) );
            //connecting the click
            QObject::connect( this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SIGNAL(open_map_by_click(QString)),
                              this, SIGNAL(loadMap(QString)));
            //connecting the zoomingz
            QObject::connect( this->btnZoom64, SIGNAL(clicked()),
                              this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SLOT(scale_icon_to_64()));
            QObject::connect( this->btnZoom128, SIGNAL(clicked()),
                              this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SLOT(scale_icon_to_128()));
            QObject::connect( this->btnZoom256, SIGNAL(clicked()),
                              this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SLOT(scale_icon_to_256()));
            QObject::connect( mb, SIGNAL(please_refresh_as_we_deleted_something()),
                             this, SLOT(reload()) );
        }
    }
    //secound we fetch all the *.map.preview and store em in this->scroll_widget->entryPixmaps
//    for ( int i = 1; i < this->inside_widget->entries.count(); i++ )
//    {
//        str = list[ i ];
//        if ( str.right( 12 ) == ".map.preview" )
//            this->inside_widget->entries[ i ]->setIcon( QIcon( this->projectPath + "/maps/" + str ) );
//    }
//    this->inside_widget->setBasementSizez( this->scrollView_insW->size().width() );
    this->inside_widget->setZoomFactor( this->inside_widget->zoom_factor );
//    this->inside_widget->realign_entries();
}
Beispiel #2
0
cmap_array_widget::cmap_array_widget(QWidget *parentz, QString projectPathz)
{
    this->projectPath = projectPathz;
    this->setParent( parentz );

    //*** setting up head bar
    this->headbar = new QWidget;
    this->headbar->setStyleSheet("QWidget { color: white;background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #353535, stop: 0.1 #494949, stop: 0.49 #626262, stop: 0.5 #626262, stop: 1 #676767);border-width: 1px;border-color: #339;border-style: solid;border-radius: 4; } ");
    this->headbar->setMaximumHeight( 30 );
    this->headbar->setMinimumHeight( 30 );
    this->btnNew = new QLabel2( this );
    this->btnNew->setPixmap( QPixmap( ":/resources/img/add.png" ) );
    this->btnNew->setScaledContents( true );
    this->btnNew->setMinimumSize( 24,24 );
    this->btnNew->setMaximumSize( 24,24 );
    this->btnRefresh = new QLabel2( this );
    this->btnRefresh->setPixmap( QPixmap( ":/resources/img/refresh.png" ) );
    this->btnRefresh->setScaledContents( true );
    this->btnRefresh->setMinimumSize( 24,24 );
    this->btnRefresh->setMaximumSize( 24,24 );
    this->btnOpenManual = new QLabel2( this );
    this->btnOpenManual->setPixmap( QPixmap( ":/resources/img/open_map.png" ) );
    this->btnOpenManual->setScaledContents( true );
    this->btnOpenManual->setMinimumSize( 24,24 );
    this->btnOpenManual->setMaximumSize( 24,24 );
    this->btnZoom64  = new QLabel2( this );
    this->btnZoom64->setPixmap( QPixmap( ":/resources/img/zoomout.png" ) );
    this->btnZoom64->setScaledContents( true );
    this->btnZoom64->setMinimumSize( 24,24 );
    this->btnZoom64->setMaximumSize( 24,24 );
    this->btnZoom128 = new QLabel2( this );
    this->btnZoom128->setPixmap( QPixmap( ":/resources/img/zoom.png" ) );
    this->btnZoom128->setScaledContents( true );
    this->btnZoom128->setMinimumSize( 24,24 );
    this->btnZoom128->setMaximumSize( 24,24 );
    this->btnZoom256 = new QLabel2( this );
    this->btnZoom256->setPixmap( QPixmap( ":/resources/img/zoomin.png" ) );
    this->btnZoom256->setScaledContents( true );
    this->btnZoom256->setMinimumSize( 24,24 );
    this->btnZoom256->setMaximumSize( 24,24 );

    //layouting the head bar
    this->headbar_layout = new QHBoxLayout( this );
    this->headbar_layout->addWidget( this->btnNew );
    this->headbar_layout->addWidget( this->btnRefresh );
    this->headbar_layout->addWidget( this->btnOpenManual );
    this->headbar_layout->addStretch();
    this->headbar_layout->addWidget( this->btnZoom64 );
    this->headbar_layout->addWidget( this->btnZoom128 );
    this->headbar_layout->addWidget( this->btnZoom256 );
    this->headbar_layout->setMargin( 3 );
    this->headbar->setLayout( this->headbar_layout );

    //connecting zoom buttonz
    QObject::connect( this->btnZoom64, SIGNAL(clicked()), this, SLOT(setZoom64()) );
    QObject::connect( this->btnZoom128, SIGNAL(clicked()), this, SLOT(setZoom128()) );
    QObject::connect( this->btnZoom256, SIGNAL(clicked()), this, SLOT(setZoom256()) );

    QObject::connect( this->btnNew, SIGNAL(clicked()),
                      this, SIGNAL(newMap()) );
    QObject::connect( this->btnRefresh, SIGNAL(clicked()),
                      this, SLOT(reload()));
    QObject::connect( this->btnOpenManual, SIGNAL(clicked()),
                      this, SLOT(openManual()));


    //setting up all the interesting widgets from the most inner
    // to the most outside one
    //1. this->frame_widget
    //2. this->scrollView_insW
    //3. this->inside_widget

    //here the scroll stuff
    this->scrollView_insW = new QScrollArea( this );
    this->scrollView_insW->setBackgroundRole( QPalette::Dark );
    this->scrollView_insW->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
//    this->scrollView_insW->setWidget( this->inside_widget );

    //fame widget stuff
    this->frame_widget = new CFrameWidget();
    this->frame_widget_layout = new QVBoxLayout( );
//    this->frame_widget_layout->setContentsMargins( 36, 36, 36, 36 );
    this->frame_widget_layout->setMargin( 40 );
    this->frame_widget_layout->setAlignment( this, Qt::AlignCenter );
    this->frame_widget_layout->addWidget( this->headbar );
    this->frame_widget_layout->addWidget( this->scrollView_insW );
    this->frame_widget->setLayout( this->frame_widget_layout );

    // this feeds the this->inside_widget 's entries
    this->inside_widget = new CInside_widget();
    this->reload();
    this->inside_widget->setBasementSizez( this->scrollView_insW->size().width() );

    //setting up gui/ layouting
    this->main_layout = new QVBoxLayout( this );
//    this->main_layout->addWidget( this->headbar );
    this->main_layout->addWidget( this->frame_widget );
    this->main_layout->setMargin( 0 );
    this->setLayout( this->main_layout );

    this->frame_widget->regenerateFrame();
//    this->inside_widget->setMinimumSize( this->scrollView_insW->width() - 17, this->scrollView_insW->height() - 17 );


}
Beispiel #3
0
/**
	MainWindow represents, not surprisingly, the main window of the application.
	It handles all the menu items and the UI.
*/
MainWindow::MainWindow( ) : QMainWindow( 0 )
{
  setupUi(this);
  
  // add the file dropdown to the toolbar...can't do this in Designer for some reason
  QWidget *stretch = new QWidget(toolBar);
  stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
  toolBar->addWidget(stretch);
  currentFileDropDown = new QComboBox(toolBar);
  currentFileDropDown->setSizeAdjustPolicy(QComboBox::AdjustToContents);
  toolBar->addWidget(currentFileDropDown);
  QWidget *pad = new QWidget(toolBar); // this doesn't pad as much as it should...to be fixed...
  toolBar->addWidget(pad);
  
  //initialization
  buildLog = new BuildLog();
  highlighter = new Highlighter( editor->document() );
  prefs = new Preferences(this);
  projInfo = new ProjectInfo(this);
  uploader = new Uploader(this);
  builder = new Builder(this, projInfo, buildLog);
  usbConsole = new UsbConsole();
  findReplace = new FindReplace(this);
  about = new About();
  updater = new AppUpdater();
  
  // load
  boardTypeGroup = new QActionGroup(menuBoard_Type);
  loadBoardProfiles( );
  loadExamples( );
  loadLibraries( );
  loadRecentProjects( );
  readSettings( );
  
  // misc. signals
  connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(onCursorMoved()));
  connect(actionPreferences, SIGNAL(triggered()), prefs, SLOT(loadAndShow()));
  connect(actionUsb_Monitor, SIGNAL(triggered()), usbConsole, SLOT(loadAndShow()));
  connect(currentFileDropDown, SIGNAL(currentIndexChanged(int)), this, SLOT(onFileSelection(int)));
  connect(editor->document(), SIGNAL(contentsChanged()),this, SLOT(onDocumentModified()));
  connect(outputConsole, SIGNAL(itemDoubleClicked(QListWidgetItem*)),this, SLOT(onConsoleDoubleClick(QListWidgetItem*)));
  connect(projInfo, SIGNAL(projectInfoUpdated()), builder, SLOT(onProjectUpdated()));
  
  // menu actions 
  connect(actionNew,					SIGNAL(triggered()), this,		SLOT(onNewFile()));
  connect(actionAdd_Existing_File, SIGNAL(triggered()), this,		SLOT(onAddExistingFile()));
  connect(actionNew_Project,	SIGNAL(triggered()), this,		SLOT(onNewProject()));
  connect(actionOpen,					SIGNAL(triggered()), this,		SLOT(onOpen()));
  connect(actionSave,					SIGNAL(triggered()), this,		SLOT(onSave()));
  connect(actionSave_As,			SIGNAL(triggered()), this,		SLOT(onSaveAs()));
  connect(actionBuild,				SIGNAL(triggered()), this,		SLOT(onBuild()));
  connect(actionStop,         SIGNAL(triggered()), this,		SLOT(onStop()));
  connect(actionClean,				SIGNAL(triggered()), this,		SLOT(onClean()));
  connect(actionProperties,		SIGNAL(triggered()), this,		SLOT(onProperties()));
  connect(actionUpload,				SIGNAL(triggered()), this,		SLOT(onUpload()));
  connect(actionUndo,					SIGNAL(triggered()), editor,	SLOT(undo()));
  connect(actionRedo,					SIGNAL(triggered()), editor,	SLOT(redo()));
  connect(actionCut,					SIGNAL(triggered()), editor,	SLOT(cut()));
  connect(actionCopy,					SIGNAL(triggered()), editor,	SLOT(copy()));
  connect(actionPaste,				SIGNAL(triggered()), editor,	SLOT(paste()));
  connect(actionSelect_All,		SIGNAL(triggered()), editor,	SLOT(selectAll()));
  connect(actionFind,         SIGNAL(triggered()), findReplace,	SLOT(show()));
  connect(actionAbout,        SIGNAL(triggered()), about,   SLOT(show()));
  connect(actionUpdate,        SIGNAL(triggered()), this,   SLOT(onUpdate()));
  connect(actionBuildLog, SIGNAL(triggered()), buildLog, SLOT(show()));
  connect(actionVisitForum,        SIGNAL(triggered()), this,   SLOT(onVisitForum()));
  connect(actionClear_Output_Console,		SIGNAL(triggered()), outputConsole,	SLOT(clear()));
  connect(actionUpload_File_to_Board,		SIGNAL(triggered()), this,	SLOT(onUploadFile()));
  connect(actionMake_Controller_Reference, SIGNAL(triggered()), this, SLOT(openMCReference()));
  connect(actionMcbuilder_User_Manual, SIGNAL(triggered()), this, SLOT(openManual()));
  connect(menuExamples, SIGNAL(triggered(QAction*)), this, SLOT(onExample(QAction*)));
  connect(menuLibraries, SIGNAL(triggered(QAction*)), this, SLOT(onLibrary(QAction*)));
  connect(actionSave_Project_As, SIGNAL(triggered()), this, SLOT(onSaveProjectAs()));
  connect(menuRecent_Projects, SIGNAL(triggered(QAction*)), this, SLOT(openRecentProject(QAction*)));
}