Esempio n. 1
0
/* QPlasmaPakFile */
QPlasmaPakFile::QPlasmaPakFile(QWidget* parent)
              : QPlasmaDocument(kDocPackage, parent)
{
    fFileList = new QTreeWidget(this);
    fFileList->setUniformRowHeights(true);
    fFileList->setRootIsDecorated(false);
    fFileList->setEditTriggers(QAbstractItemView::SelectedClicked |
                               QAbstractItemView::EditKeyPressed);
    fFileList->setContextMenuPolicy(Qt::CustomContextMenu);
    fFileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
    fFileList->setHeaderLabels(QStringList() << "Filename" << "Size");

    QToolBar* toolbar = new QToolBar(this);
    toolbar->setOrientation(Qt::Vertical);
    toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    toolbar->setIconSize(QSize(22, 22));

    QGridLayout* layout = new QGridLayout(this);
    layout->setContentsMargins(4, 4, 4, 4);
    layout->addWidget(fFileList, 0, 0);
    layout->addWidget(toolbar, 0, 1);
    setLayout(layout);

    fActions[kAdd] = new QAction(qStdIcon("list-add"), tr("&Add / Update..."), this);
    fActions[kDel] = new QAction(qStdIcon("list-remove"), tr("&Delete"), this);
    fActions[kExtract] = new QAction(qStdIcon("document-save"), tr("&Extract..."), this);
    fActions[kExtractAll] = new QAction(QIcon(":/img/pak.png"), tr("Ex&tract all..."), this);

    toolbar->addAction(fActions[kAdd]);
    toolbar->addAction(fActions[kDel]);
    toolbar->addSeparator();
    toolbar->addAction(fActions[kExtract]);
    toolbar->addAction(fActions[kExtractAll]);

    connect(fFileList, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(onContextMenu(QPoint)));
    connect(fActions[kAdd], SIGNAL(triggered()), this, SLOT(onAdd()));
    connect(fActions[kDel], SIGNAL(triggered()), this, SLOT(onDel()));
    connect(fActions[kExtract], SIGNAL(triggered()), this, SLOT(onExtract()));
    connect(fActions[kExtractAll], SIGNAL(triggered()), this, SLOT(onExtractAll()));
}
Esempio n. 2
0
QPlasmaSumFile::QPlasmaSumFile(QWidget* parent)
              : QPlasmaDocument(kDocManifest, parent)
{
    fFileList = new QTreeWidget(this);
    fFileList->setUniformRowHeights(true);
    fFileList->setRootIsDecorated(false);
    fFileList->setEditTriggers(QAbstractItemView::SelectedClicked |
                               QAbstractItemView::EditKeyPressed);
    fFileList->setContextMenuPolicy(Qt::CustomContextMenu);
    fFileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
    fFileList->setHeaderLabels(QStringList() << "Filename" << "Timestamp" << "MD5");

    QToolBar* toolbar = new QToolBar(this);
    toolbar->setOrientation(Qt::Vertical);
    toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    toolbar->setIconSize(QSize(22, 22));

    QGridLayout* layout = new QGridLayout(this);
    layout->setContentsMargins(4, 4, 4, 4);
    layout->addWidget(fFileList, 0, 0);
    layout->addWidget(toolbar, 0, 1);
    setLayout(layout);

    fActions[kAUpdate] = new QAction(qStdIcon("view-refresh"), tr("&Update all..."), this);
    fActions[kAAdd] = new QAction(qStdIcon("list-add"), tr("&Add / Update..."), this);
    fActions[kADel] = new QAction(qStdIcon("list-remove"), tr("&Remove"), this);

    toolbar->addAction(fActions[kAUpdate]);
    toolbar->addSeparator();
    toolbar->addAction(fActions[kAAdd]);
    toolbar->addAction(fActions[kADel]);

    connect(fFileList, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(onContextMenu(QPoint)));
    connect(fFileList, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
            this, SLOT(onItemChanged(QTreeWidgetItem*, int)));
    connect(fActions[kAUpdate], SIGNAL(triggered()), this, SLOT(onUpdate()));
    connect(fActions[kAAdd], SIGNAL(triggered()), this, SLOT(onAdd()));
    connect(fActions[kADel], SIGNAL(triggered()), this, SLOT(onDel()));
}
Esempio n. 3
0
/* Find/Replace dialog */
TextFindDialog::TextFindDialog(QPlasmaTextDoc* parent, bool replace)
              : QDialog(parent)
{
    s_findSettings.current = this;
    fDocument = parent;
    setAttribute(Qt::WA_DeleteOnClose);
    if (replace) {
        setWindowTitle(tr("Replace..."));
        setWindowIcon(qStdIcon("edit-find-replace"));
    } else {
        setWindowTitle(tr("Find..."));
        setWindowIcon(qStdIcon("edit-find"));
    }

    fFindText = new QLineEdit(s_findSettings.text, this);
    if (replace)
        fNewText = new QLineEdit(s_findSettings.newText, this);
    else
        fNewText = NULL;
    fCaseSensitive = new QCheckBox(tr("&Case sensitive"), this);
    fRegEx = new QCheckBox(tr("&Regular expression search"), this);
    fWholeWord = new QCheckBox(tr("Match &whole word"), this);
    fReverse = new QCheckBox(tr("Search &up"), this);
    fFindText->selectAll();
    fCaseSensitive->setChecked(s_findSettings.cs);
    fRegEx->setChecked(s_findSettings.regex);
    fWholeWord->setChecked(s_findSettings.wo);
    fReverse->setChecked(s_findSettings.reverse);

    QWidget* buttonPanel = new QWidget(this);
    QPushButton* btnFind = new QPushButton(replace ? tr("&Replace") : tr("&Find"), buttonPanel);
    QPushButton* btnReplaceAll = NULL;
    if (replace) {
        btnReplaceAll = new QPushButton(tr("Replace &All"), buttonPanel);
        fBtnSkip = new QPushButton(tr("&Skip"), buttonPanel);
        fBtnSkip->setEnabled(false);
    }
    QPushButton* btnCancel = new QPushButton(tr("&Cancel"), buttonPanel);

    QGridLayout* buttonLayout = new QGridLayout(buttonPanel);
    buttonLayout->setContentsMargins(0, 0, 0, 0);
    buttonLayout->setVerticalSpacing(4);
    int idx = 0;
    buttonLayout->addWidget(btnFind, idx++, 0);
    if (replace) {
        buttonLayout->addWidget(btnReplaceAll, idx++, 0);
        buttonLayout->addWidget(fBtnSkip, idx++, 0);
    }
    buttonLayout->addWidget(btnCancel, idx++, 0);
    buttonLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), idx, 0);

    QGridLayout* layout = new QGridLayout(this);
    layout->setContentsMargins(8, 8, 8, 8);
    layout->setVerticalSpacing(4);
    layout->setHorizontalSpacing(8);
    idx = 0;
    layout->addWidget(new QLabel(tr("Search string:"), this), idx, 0);
    layout->addWidget(fFindText, idx++, 1);
    if (replace) {
        layout->addWidget(new QLabel(tr("Replace with:"), this), idx, 0);
        layout->addWidget(fNewText, idx++, 1);
    }
    layout->addItem(new QSpacerItem(0, 16, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum), idx++, 0, 1, 2);
    layout->addWidget(fCaseSensitive, idx++, 1);
    layout->addWidget(fRegEx, idx++, 1);
    layout->addWidget(fWholeWord, idx++, 1);
    layout->addWidget(fReverse, idx++, 1);
    layout->addWidget(buttonPanel, 0, 2, idx, 1);

    connect(btnFind, SIGNAL(clicked()), this, SLOT(handleFind()));
    connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
    if (replace) {
        connect(btnReplaceAll, SIGNAL(clicked()), this, SLOT(handleReplaceAll()));
        connect(fBtnSkip, SIGNAL(clicked()), this, SLOT(handleSkip()));
    }

    resize(sizeHint().width() * 1.5, sizeHint().height());
}
Esempio n. 4
0
/* VaultShopMain */
VaultShopMain::VaultShopMain()
{
    // Basic Form Settings
    setWindowTitle("VaultShop " PLASMASHOP_VERSION);
    //setWindowIcon(QIcon(":/res/VaultShop.png"));

    // Set up actions
    fActions[kFileOpenVault] = new QAction(qStdIcon("document-open"), tr("&Load Vault..."), this);
    fActions[kFileSaveVault] = new QAction(qStdIcon("document-save"), tr("&Save Vault"), this);
    fActions[kFileExit] = new QAction(tr("E&xit"), this);
    fActions[kVaultOpenNode] = new QAction(tr("Subscribe to &Node..."), this);

    fActions[kNodeUnLink] = new QAction(tr("Remove"), this);
    fActions[kNodeLink] = new QAction(tr("Add Node..."), this);
    fActions[kNodeCreate] = new QAction(tr("Create Node"), this);
    fActions[kNodeUnsubscribe] = new QAction(tr("Un-subscribe"), this);
    //fActions[kNodeRenameVault] = new QAction(tr("Rename Vault..."), this);

    fActions[kFileOpenVault]->setShortcut(Qt::CTRL + Qt::Key_O);
    fActions[kFileSaveVault]->setShortcut(Qt::CTRL + Qt::Key_S);
    fActions[kFileExit]->setShortcut(Qt::ALT + Qt::Key_F4);
    fActions[kVaultOpenNode]->setShortcut(Qt::Key_F2);

    // Main Menus
    QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
    fileMenu->addAction(fActions[kFileOpenVault]);
    fileMenu->addAction(fActions[kFileSaveVault]);
    fileMenu->addSeparator();
    fileMenu->addAction(fActions[kFileExit]);

    QMenu* vaultMenu = menuBar()->addMenu(tr("&Vault"));
    vaultMenu->addAction(fActions[kVaultOpenNode]);

    // Toolbars
    QToolBar* fileTbar = addToolBar(tr("File Toolbar"));
    fileTbar->setObjectName("FileToolBar");
    fileTbar->addAction(fActions[kFileOpenVault]);
    fileTbar->addAction(fActions[kFileSaveVault]);
    statusBar();

    // Main Splitter
    QSplitter* splitter = new QSplitter(Qt::Horizontal, this);
    splitter->setObjectName("Splitter");

    // Node Browser
    fVaultTree = new QTreeWidget(splitter);
    fVaultTree->setUniformRowHeights(true);
    fVaultTree->setHeaderHidden(true);
    fVaultTree->setContextMenuPolicy(Qt::CustomContextMenu);

    // Property Editor
    fNodeTab = new QTabWidget(splitter);
    fGenericEditor = new QVaultNode(fNodeTab);
    fNodeTab->addTab(fGenericEditor, tr("Node Properties"));
    fCustomEditor = NULL;
    fSavEditor = NULL;
    fEditorTabPreference = 0;

    // Layout
    splitter->addWidget(fVaultTree);
    splitter->addWidget(fNodeTab);
    setCentralWidget(splitter);
    splitter->setSizes(QList<int>() << 160 << 320);

    // Global UI Signals
    connect(fActions[kFileExit], SIGNAL(triggered()), this, SLOT(close()));
    connect(fActions[kFileOpenVault], SIGNAL(triggered()), this, SLOT(openGame()));
    connect(fActions[kFileSaveVault], SIGNAL(triggered()), this, SLOT(performSave()));
    connect(fActions[kVaultOpenNode], SIGNAL(triggered()), this, SLOT(openNode()));
    connect(fActions[kNodeUnLink], SIGNAL(triggered()), this, SLOT(unlinkNode()));
    connect(fActions[kNodeLink], SIGNAL(triggered()), this, SLOT(linkNode()));
    connect(fActions[kNodeCreate], SIGNAL(triggered()), this, SLOT(createNode()));
    connect(fActions[kNodeUnsubscribe], SIGNAL(triggered()), this, SLOT(closeNode()));
    //connect(fActions[kNodeRenameVault], SIGNAL(triggered()), this, SLOT(renameVault()));

    connect(fVaultTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
            this, SLOT(treeItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
    connect(fVaultTree, SIGNAL(customContextMenuRequested(const QPoint&)),
            this, SLOT(treeContextMenu(const QPoint&)));
    connect(fNodeTab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
    connect(fGenericEditor, SIGNAL(typeModified()), this, SLOT(typeModified()));
    connect(this, SIGNAL(nodeChanged(unsigned int)), this, SLOT(refreshNode(unsigned int)));

    // Load UI Settings
    QSettings settings("PlasmaShop", "VaultShop");
    resize(settings.value("WinSize", QSize(480, 600)).toSize());
    if (settings.contains("WinPos"))
        move(settings.value("WinPos").toPoint());
    if (settings.value("WinMaximized", false).toBool())
        showMaximized();

    if (settings.contains("WinState"))
        restoreState(settings.value("WinState").toByteArray());

    fLastDir = settings.value("LastDir").toString();
    if (!fLastDir.isEmpty())
        loadGame(fLastDir);
}