Skip to content

Commit

Permalink
update: versioninfo copy
Browse files Browse the repository at this point in the history
  • Loading branch information
r3yc0n1c committed Mar 18, 2024
2 parents 6bb001a + cf23b1e commit 84fac11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
40 changes: 19 additions & 21 deletions src/dialogs/VersionInfoDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

VersionInfoDialog::VersionInfoDialog(QWidget *parent)
: QDialog(parent), ui(new Ui::VersionInfoDialog), core(Core())
{
{
ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));

Expand All @@ -25,35 +25,32 @@ VersionInfoDialog::VersionInfoDialog(QWidget *parent)
copyActionLeftTreewidget->setIcon(QIcon(":/img/icons/copy.svg"));
copyActionLeftTreewidget->setShortcut(QKeySequence::StandardKey::Copy);
copyActionLeftTreewidget->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);

copyActionRightTreewidget = new QAction(tr("Copy"), this);
copyActionRightTreewidget->setIcon(QIcon(":/img/icons/copy.svg"));
copyActionRightTreewidget->setShortcut(QKeySequence::StandardKey::Copy);
copyActionRightTreewidget->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);

selAllActionLeftTreewidget = new QAction(tr("Select All"), this);
selAllActionLeftTreewidget->setShortcut(QKeySequence::StandardKey::SelectAll);
selAllActionLeftTreewidget->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);

selAllActionRightTreewidget = new QAction(tr("Select All"), this);
selAllActionRightTreewidget->setShortcut(QKeySequence::StandardKey::SelectAll);
selAllActionRightTreewidget->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut);

connect(copyActionLeftTreewidget, &QAction::triggered, this, [this](){
CopyTreeWidgetSelection(ui->leftTreeWidget);
});
selAllActionRightTreewidget->setShortcutContext(
Qt::ShortcutContext::WidgetWithChildrenShortcut);

connect(copyActionRightTreewidget, &QAction::triggered, this, [this](){
CopyTreeWidgetSelection(ui->rightTreeWidget);
});
connect(copyActionLeftTreewidget, &QAction::triggered, this,
[this]() { CopyTreeWidgetSelection(ui->leftTreeWidget); });

connect(selAllActionLeftTreewidget, &QAction::triggered, this, [this](){
ui->leftTreeWidget->selectAll();
});
connect(copyActionRightTreewidget, &QAction::triggered, this,
[this]() { CopyTreeWidgetSelection(ui->rightTreeWidget); });

connect(selAllActionRightTreewidget, &QAction::triggered, this, [this](){
ui->rightTreeWidget->selectAll();
});
connect(selAllActionLeftTreewidget, &QAction::triggered, this,
[this]() { ui->leftTreeWidget->selectAll(); });

connect(selAllActionRightTreewidget, &QAction::triggered, this,
[this]() { ui->rightTreeWidget->selectAll(); });

ui->leftTreeWidget->addAction(copyActionLeftTreewidget);
ui->leftTreeWidget->addAction(selAllActionLeftTreewidget);
Expand All @@ -67,11 +64,11 @@ VersionInfoDialog::VersionInfoDialog(QWidget *parent)
VersionInfoDialog::~VersionInfoDialog() {}

void VersionInfoDialog::CopyTreeWidgetSelection(QTreeWidget *t)
{
const int keyColumnIndex = 0, valueColumnIndex = 1;
{
const int keyColumnIndex = 0, valueColumnIndex = 1;
QString vinfo, row;

for(QTreeWidgetItem *x: t->selectedItems()){
for (QTreeWidgetItem *x : t->selectedItems()) {
row = x->text(keyColumnIndex) + " = " + x->text(valueColumnIndex) + "\n";
vinfo.append(row);
}
Expand All @@ -80,7 +77,8 @@ void VersionInfoDialog::CopyTreeWidgetSelection(QTreeWidget *t)
clipboard->setText(vinfo.trimmed());
}

void VersionInfoDialog::contextMenuEvent(QContextMenuEvent *event){
void VersionInfoDialog::contextMenuEvent(QContextMenuEvent *event)
{
contextMenu->exec(event->globalPos());
event->accept();
}
Expand Down
6 changes: 3 additions & 3 deletions src/dialogs/VersionInfoDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ class VersionInfoDialog : public QDialog
Q_OBJECT

public:
explicit VersionInfoDialog(QWidget *parent = nullptr);
explicit VersionInfoDialog(QWidget *parent = nullptr);
~VersionInfoDialog();

private slots:
void CopyTreeWidgetSelection(QTreeWidget *t);

protected:
QMenu *contextMenu = nullptr;
QMenu *contextMenu = nullptr;
QAction *copyActionLeftTreewidget = nullptr;
QAction *copyActionRightTreewidget = nullptr;
QAction *selAllActionLeftTreewidget = nullptr;
QAction *selAllActionRightTreewidget = nullptr;

void contextMenuEvent(QContextMenuEvent *event) override;

private:
Expand Down

0 comments on commit 84fac11

Please sign in to comment.