示例#1
0
void UEFITool::saveImageFile()
{
    QString path = QFileDialog::getSaveFileName(this, tr("Save BIOS image file"),".","BIOS image files (*.rom *.bin *.cap *.bio *.fd *.wph *.efi);;All files (*.*)");
    
    if (path.isEmpty())
        return;

    QByteArray reconstructed;
    UINT8 result = ffsEngine->reconstructImageFile(reconstructed);
    showMessages();
    if (result) {
        QMessageBox::critical(this, tr("Image reconstruction failed"), tr("Error code: %1").arg(result), QMessageBox::Ok);
        return;
    }

    QFile outputFile;
    outputFile.setFileName(path);
    if (!outputFile.open(QFile::WriteOnly)) {
        QMessageBox::critical(this, tr("Image reconstruction failed"), tr("Can't open output file for rewriting"), QMessageBox::Ok);
        return;
    }

    outputFile.resize(0);
    outputFile.write(reconstructed);
    outputFile.close();
    if (QMessageBox::information(this, tr("Image reconstruction successful"), tr("Open reconstructed file?"), QMessageBox::Yes, QMessageBox::No)
        == QMessageBox::Yes)
        openImageFile(path);
}
//==============================================================================
bool MainContentComponent::perform(const InvocationInfo &info)
{
    MainWindow *pMainWindow = MainWindow::getMainWindow();
    if(pMainWindow == nullptr)
    {        
        return true;
    }

    switch (info.commandID)
    {
    case MainWindow::fileOpen: openImageFile();
        break;
    case MainWindow::useLookAndFeelV1:
        LookAndFeel::setDefaultLookAndFeel(&mLookAndFeelV1);
        break;
    case MainWindow::useLookAndFeelV2:
        LookAndFeel::setDefaultLookAndFeel(&mLookAndFeelV2);
        break;
    case MainWindow::useLookAndFeelV3:
        LookAndFeel::setDefaultLookAndFeel(&mLookAndFeelV3);
        break;
    case MainWindow::useNativeStyle:
        pMainWindow->setUsingNativeTitleBar(!pMainWindow->isUsingNativeTitleBar());
        break;
    case MainWindow::showFileTreeView:
    {
        if (mFileTreeVisible)   //> change to ImageComponent only
        {
            mStretchableManager.setItemLayout(0, 0, 0, 0);
            mStretchableManager.setItemLayout(1, 0, 0, 0);
            mStretchableManager.setItemLayout(2, -1.0, -1.0, -1.0);
        }
        else    //> FileTreeComponent + StretchableLayoutResizerBar + ImageComponent
        {
            mStretchableManager.setItemLayout(0, -0.1, -0.8, -0.1);
            mStretchableManager.setItemLayout(1, 5, 5, 5);
            mStretchableManager.setItemLayout(2, -0.2, -0.9, -0.9);            
        }

        //> change state
        mFileTreeVisible = !mFileTreeVisible;

        //> relayout
        Component *comps[] = { &mFileTree, &mResizerBar, &mImgViewer };
        const int pxShift = 4;
        Rectangle<int> r(getBounds().reduced(pxShift));

        mStretchableManager.layOutComponents(comps, numElementsInArray(comps),
            r.getX(), r.getY() + LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight(),
            r.getWidth(), r.getHeight() - LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight(),
            false, true);

        break;
    }
    default:
        return false;
    }

    return true;
}
示例#3
0
void Viewer::chooseFile()
{
    QString imageFile = QFileDialog::getOpenFileName(this,
        tr("Choose an image file to open"), path, tr("Images (*.*)"));

    if (!imageFile.isEmpty()) {
        openImageFile(imageFile);
        path = imageFile;
    }
}
示例#4
0
void MainWindow::createActions()
{
	openAct = new QAction("&Open", this);
	connect(openAct, SIGNAL(triggered()), this, SLOT(openImageFile()));

	exitAct = new QAction("E&xit", this);
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    aboutAct = new QAction("&About", this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    
    statAct = new QAction("&Stat", this);
    connect(statAct, SIGNAL(triggered()), this, SLOT(showStat()));
}
示例#5
0
UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::UEFITool), 
version(tr("0.18.7"))
{
    clipboard = QApplication::clipboard();

    // Create UI
    ui->setupUi(this);
    searchDialog = new SearchDialog(this);
    ffsEngine = NULL;

	// Set window title
	this->setWindowTitle(tr("UEFITool %1").arg(version));

    // Connect signals to slots
    connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile()));
    connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile()));
    connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
    connect(ui->actionExtract, SIGNAL(triggered()), this, SLOT(extractAsIs()));
    connect(ui->actionExtractBody, SIGNAL(triggered()), this, SLOT(extractBody()));
    connect(ui->actionInsertInto, SIGNAL(triggered()), this, SLOT(insertInto()));
    connect(ui->actionInsertBefore, SIGNAL(triggered()), this, SLOT(insertBefore()));
    connect(ui->actionInsertAfter, SIGNAL(triggered()), this, SLOT(insertAfter()));
    connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(replaceAsIs()));
    connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody()));
    connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
    connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
    connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage()));
    connect(ui->actionMessagesCopyAll, SIGNAL(triggered()), this, SLOT(copyAllMessages()));
    connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit()));
    connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings()));

    // Enable Drag-and-Drop actions
    this->setAcceptDrops(true);

    // Set current directory
    currentDir = ".";

    // Initialize non-persistent data
    init();

    // Read stored settings
    readSettings();
}
void ossimQtVceCanvasWidget::addAllObjects(const ossimKeywordlist& kwl,
                                           const QPoint& location,
                                           const char* prefix)
{
   unselectItems();
   QPoint locationPoint = location;
   
   ossimString copyPrefix = prefix;
   std::vector<QCanvasItem*> newItemList;
   
   ossimString regExpression =  ossimString("^(") + copyPrefix + "object[0-9]+.)";
   vector<ossimString> keys =
      kwl.getSubstringKeyList( regExpression );
   long numberOfObjets = keys.size();//kwl.getNumberOfSubstringKeys(regExpression);

   int offset = (copyPrefix+"object").size();
   int idx = 0;
   std::vector<int> theNumberList(numberOfObjets);

   for(idx = 0; idx < (int)theNumberList.size();++idx)
   {
      ossimString numberStr(keys[idx].begin() + offset,
                            keys[idx].end());
      theNumberList[idx] = numberStr.toInt();
   }
   
   std::sort(theNumberList.begin(), theNumberList.end());
   for(idx=0;idx < (int)theNumberList.size();++idx)
   {
      ossimString newPrefix = copyPrefix;
      newPrefix += ossimString("object");
      newPrefix += ossimString::toString(theNumberList[idx]);
      newPrefix += ossimString(".");
      ossimString objType = kwl.find(newPrefix,
                                     ossimKeywordNames::TYPE_KW);
      QCanvasItem* item = NULL;
      if(objType == "ossimQtImageWindow")
      {
         item = new ossimQtVceImageDisplayObject(canvas(),
						 this);
         item->setX(locationPoint.x());
         item->setY(locationPoint.y());
         item->show();
         emit itemAdded(item);
      }
      else if(objType == "ossimImageHandler")
      {
         QStringList filenames = QFileDialog::getOpenFileNames("Images (*.adf *.ccf *.dem *.DEM *.dt1 *.dt0 *.dt2 *.hdr *.hgt *.jpg *.jpeg *.img *.doqq *.fst *.FST *.nitf *.NTF *.ntf *.ras *.sid *.tif *.tiff *.toc *.TOC);;Vectors(*.shp dht *.tab);;All Files(*)",
                                                               QString::null,
                                                               this,
                                                               "open file dialog",
                                                               "Choose a file to open");
         QStringList::Iterator it;
         for(it = filenames.begin(); it != filenames.end(); ++it)
         {
            std::vector<QCanvasItem*> newItems;
            openImageFile((*it).ascii(),
                          locationPoint,
                          newItems);
            if(newItems.size())
            {
               
//                QRect bounds = newItems[newItems.size()-1]->boundingRect();
//                locationPoint.setY(locationPoint.y() + bounds.height() + 10);

               newItemList.insert(newItemList.end(),
                                  newItems.begin(),
                                  newItems.end());
            }
         }
         // we will make sure that we don't adjust the location point any further
         //
         item = NULL;
      }
      else
      {
         ossimObject* object = ossimObjectFactoryRegistry::instance()->createObject(objType);
         
         if(object)
         {
            item = addObject(object, locationPoint);
         }
      }
      if(item)
      {
         newItemList.push_back(item);
         QRect bounds = item->boundingRect();
         
         locationPoint.setY(locationPoint.y() + bounds.height() + 10);
         emit itemAdded(item);
      }
   }
   if(newItemList.size() > 0)
   {
      for(idx = 0; idx < (int)newItemList.size(); ++idx)
      {
         newItemList[idx]->setSelected(true);
         theSelectedItems.push_back(newItemList[idx]);
         emit itemSelected(newItemList[idx]);
      }
   }
}
void ossimQtVceCanvasWidget::dropEvent(QDropEvent* event)
{
   std::vector<ossimObject*> objects;
   
   QString text;
   if ( QTextDrag::decode(event, text) )
   {
      QPoint position(event->pos().x() + contentsX(),
                      event->pos().y() + contentsY());
      ossimKeywordlist kwl;
      stringstream in(text.ascii());
      bool kwlParseFlag = kwl.parseStream(in);
      const char* type = NULL;
      if(kwlParseFlag)
      {
         type = kwl.find(ossimKeywordNames::TYPE_KW);
      }
      if(ossimString(type) == "ossimDataManagerObjectList")
      {
         addAllDataManagerObjects(kwl, position);
      }
      else if(ossimString(type)=="ossimQtVceComponentView")
      {
         addAllObjects(kwl, position);
      }
      else
      {
         unselectItems();
         QString filename;
         const char* s = text.ascii();
         const char* sEnd = text.ascii()+text.length();
         int idx = 0;
         while(s < sEnd)
         {
            filename = "";
            while((*s!='\0')&&
                  (*s != '\n')&&
                  (s < sEnd)&&
                  (*s != '\r'))
            {
               filename += *s;
               ++s;
            }
            ++s;
            filename += '\0';
            if(filename != "")
            {
               filename = filename.remove("file:");
               std::vector<QCanvasItem*> newItems;
               openImageFile(filename.ascii(),
                             position,
                             newItems);
               for(idx = 0; idx < (int)newItems.size(); ++idx)
               {
                  newItems[idx]->setSelected(true);
                  theSelectedItems.push_back(newItems[idx]);
                  emit itemSelected(newItems[idx]);
               }
            }
         }
      }
   }
}
示例#8
0
void UEFITool::dropEvent(QDropEvent* event)
{
    QString path = event->mimeData()->urls().at(0).toLocalFile();
    openImageFile(path);
}
示例#9
0
void UEFITool::openImageFile()
{
    QString path = QFileDialog::getOpenFileName(this, tr("Open BIOS image file"),".","BIOS image files (*.rom *.bin *.cap *.bio *.fd *.wph *.efi);;All files (*.*)");
    openImageFile(path);
}
示例#10
0
UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::UEFITool), 
version(tr("0.20.4"))
{
    clipboard = QApplication::clipboard();

    // Create UI
    ui->setupUi(this);
    searchDialog = new SearchDialog(this);
    ffsEngine = NULL;

    // Set window title
    this->setWindowTitle(tr("UEFITool %1").arg(version));

    // Connect signals to slots
    connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile()));
    connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile()));
    connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
    connect(ui->actionExtract, SIGNAL(triggered()), this, SLOT(extractAsIs()));
    connect(ui->actionExtractBody, SIGNAL(triggered()), this, SLOT(extractBody()));
    connect(ui->actionInsertInto, SIGNAL(triggered()), this, SLOT(insertInto()));
    connect(ui->actionInsertBefore, SIGNAL(triggered()), this, SLOT(insertBefore()));
    connect(ui->actionInsertAfter, SIGNAL(triggered()), this, SLOT(insertAfter()));
    connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(replaceAsIs()));
    connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody()));
    connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
    connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
    connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage()));
    connect(ui->actionMessagesCopyAll, SIGNAL(triggered()), this, SLOT(copyAllMessages()));
    connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit()));
    connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings()));

    // Enable Drag-and-Drop actions
    this->setAcceptDrops(true);

    // Set current directory
    currentDir = ".";

    // Set monospace font for some controls
    QFont font("Courier New", 10);
#if defined Q_OS_OSX
    font = QFont("Menlo", 10);
#elif defined Q_OS_WIN
    font = QFont("Consolas", 9);
#endif
    ui->infoEdit->setFont(font);
    ui->messageListWidget->setFont(font);
    ui->structureTreeView->setFont(font);
    searchDialog->ui->guidEdit->setFont(font);
    searchDialog->ui->hexEdit->setFont(font);

    // Initialize non-persistent data
    init();

    // Read stored settings
    readSettings();
}