Browse Source

Улучшена форма

Архитектурные изменения в образении к элементам формы
Исправления ошибок с загрузкой формы
Добавлен класс Executable (не написан) для выполнения программ
master
Тим 11 months ago
parent
commit
f5a6d8a135
11 changed files with 147 additions and 493 deletions
  1. 2
    1
      WBMain.cpp
  2. 4
    2
      WineBottle.pro
  3. 1
    4
      main.cpp
  4. 21
    12
      resources/forms/WBFace.ui
  5. 0
    445
      resources/forms/WBFace.ui.autosave
  6. 46
    29
      ui/WBFace.cpp
  7. 4
    0
      ui/WBFace.h
  8. 3
    0
      ui/WBUiBase.cpp
  9. 14
    0
      ui/WBUiBase.h
  10. 6
    0
      wine/Execute.cpp
  11. 46
    0
      wine/Execute.h

+ 2
- 1
WBMain.cpp View File

@@ -7,7 +7,8 @@ WBMain::WBMain(QStringList args)
exe = args.front();
args.pop_front();
if (args.count())
le_args->setText(args.join(" "));
if (le_args)
le_args->setText(args.join(" "));
setWindowTitle(exe.completeBaseName());
}
}

+ 4
- 2
WineBottle.pro View File

@@ -29,7 +29,8 @@ SOURCES += \
ui/WBUiBase.cpp \
wine/RegEdit.cpp \
WBTmp.cpp \
ui/WBFace.cpp
ui/WBFace.cpp \
wine/Execute.cpp

HEADERS += \
WBItem.h \
@@ -38,7 +39,8 @@ HEADERS += \
wine/RegEdit.h \
WBTmp.h \
ui/WBFace.h \
PEHeaders.h
PEHeaders.h \
wine/Execute.h

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin

+ 1
- 4
main.cpp View File

@@ -4,11 +4,8 @@

int main(int argc, char *argv[])
{
QStringList args;
for (int i = 1; i < argc; ++i)
args << argv[i];
QApplication a(argc, argv);
WBMain w(args);
WBMain w(a.arguments());
w.show();

return a.exec();

+ 21
- 12
resources/forms/WBFace.ui View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>330</width>
<height>364</height>
<width>335</width>
<height>476</height>
</rect>
</property>
<property name="sizePolicy">
@@ -26,13 +26,6 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="1" colspan="2">
<widget class="QCheckBox" name="needConsole">
<property name="text">
<string>Console</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="log">
<property name="text">
@@ -187,7 +180,7 @@
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QRadioButton" name="dx_ogl">
<property name="font">
<font>
@@ -203,7 +196,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QRadioButton" name="dx_csmt">
<property name="font">
<font>
@@ -216,7 +209,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QRadioButton" name="dx_nine">
<property name="font">
<font>
@@ -229,6 +222,22 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="dx_off">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Don't change</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

+ 0
- 445
resources/forms/WBFace.ui.autosave View File

@@ -1,445 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>330</width>
<height>364</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="1" colspan="2">
<widget class="QCheckBox" name="needConsole">
<property name="text">
<string>Console</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="log">
<property name="text">
<string>Logging</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<layout class="QFormLayout" name="argsLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_args">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Arguments:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="args"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="advanced">
<property name="text">
<string>Advanced parametrs</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<layout class="QGridLayout" name="bottleLayout">
<item row="0" column="3">
<layout class="QGridLayout" name="executeButtons">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="run">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Run</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="link">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16</height>
</size>
</property>
<property name="text">
<string>Create link</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_bottle">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>65</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Bottle:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="bottleList">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="2" colspan="2">
<widget class="QGroupBox" name="dxmode">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>DirectX</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="dx_ogl">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>OpenGL</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="dx_csmt">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>CSMT</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="dx_nine">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Nine</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="desktopBox">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Desktop</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="desktop_disabled">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Disable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="desktop_wine">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Wine</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="desktop_xephyr">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Xephyr</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label_desktopW">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="desktopH">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>768</number>
</property>
<property name="value">
<number>768</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_desktopH">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="desktopW">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>1024</number>
</property>
<property name="value">
<number>1024</number>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QGroupBox" name="envBox">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Environments</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPlainTextEdit" name="envs">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="plainText">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

+ 46
- 29
ui/WBFace.cpp View File

@@ -4,48 +4,65 @@ WBFace::WBFace(QWidget *parent) : WBUiBase (parent, "WBFace")
{
layout()->setSizeConstraint(QLayout::SetFixedSize);

btn_run = ui->findChild<QPushButton*>("run");
btn_link = ui->findChild<QPushButton*>("link");
btn_run = loadElement<QPushButton>("run");
btn_link = loadElement<QPushButton>("link");

cb_advanced = ui->findChild<QCheckBox*>("advanced");
cb_log = ui->findChild<QCheckBox*>("log");
cb_advanced = loadElement<QCheckBox>("advanced");
cb_log = loadElement<QCheckBox>("log");
cb_directx_off = loadElement<QCheckBox>("dx_off");

rb_desktop_disable = ui->findChild<QRadioButton*>("desktop_disabled");
rb_desktop_wine = ui->findChild<QRadioButton*>("desktop_wine");
rb_desktop_xephyr = ui->findChild<QRadioButton*>("desktop_xephyr");
rb_directx_opengl = ui->findChild<QRadioButton*>("dx_ogl");
rb_directx_csmt = ui->findChild<QRadioButton*>("dx_csmt");
rb_directx_nine = ui->findChild<QRadioButton*>("dx_nine");
rb_desktop_disable = loadElement<QRadioButton>("desktop_disabled");
rb_desktop_wine = loadElement<QRadioButton>("desktop_wine");
rb_desktop_xephyr = loadElement<QRadioButton>("desktop_xephyr");
rb_directx_opengl = loadElement<QRadioButton>("dx_ogl");
rb_directx_csmt = loadElement<QRadioButton>("dx_csmt");
rb_directx_nine = loadElement<QRadioButton>("dx_nine");

combo_bottle = ui->findChild<QComboBox*>("bottleList");
combo_bottle = loadElement<QComboBox>("bottleList");

le_args = ui->findChild<QLineEdit*>("args");
le_args = loadElement<QLineEdit>("args");

pte_envs = ui->findChild<QPlainTextEdit*>("envs");
pte_envs = loadElement<QPlainTextEdit>("envs");

spin_desktop_width = ui->findChild<QSpinBox*>("desktopW");
spin_desktop_height = ui->findChild<QSpinBox*>("desktopH");
spin_desktop_width = loadElement<QSpinBox>("desktopW");
spin_desktop_height = loadElement<QSpinBox>("desktopH");

group_envBox = ui->findChild<QGroupBox*>("envBox");
group_desktopBox = ui->findChild<QGroupBox*>("desktopBox");
group_dxmode = ui->findChild<QGroupBox*>("dxmode");
group_envBox = loadElement<QGroupBox>("envBox");
group_desktopBox = loadElement<QGroupBox>("desktopBox");
group_dxmode = loadElement<QGroupBox>("dxmode");

label_args = ui->findChild<QLabel*>("label_args");
label_args = loadElement<QLabel>("label_args");
label_desktop_width = loadElement<QLabel>("label_desktopW");
label_desktop_height = loadElement<QLabel>("label_desktopH");

if (cb_advanced == nullptr || !cb_advanced->isChecked()){
resize({0,0});
advancedToggle(false);
}

if (cb_advanced)
if (cb_advanced){
QObject::connect(cb_advanced, &QCheckBox::toggled, this, &WBFace::advancedToggle);
advancedToggle(cb_advanced->isChecked());
}

if (cb_directx_off){
QObject::connect(cb_directx_off, &QCheckBox::toggled, this, &WBFace::directxToggle);
directxToggle(cb_directx_off->isChecked());
}

if (rb_desktop_disable){

}
}

void WBFace::advancedToggle(const bool toggle)
{
le_args->setVisible(toggle);
group_envBox->setVisible(toggle);
group_desktopBox->setVisible(toggle);
group_dxmode->setVisible(toggle);
label_args->setVisible(toggle);
element(le_args)->setVisible(toggle);
element(group_envBox)->setVisible(toggle);
element(group_desktopBox)->setVisible(toggle);
element(group_dxmode)->setVisible(toggle);
element(label_args)->setVisible(toggle);
}

void WBFace::directxToggle(const bool toggle)
{
element(rb_directx_opengl)->setDisabled(toggle);
element(rb_directx_csmt)->setDisabled(toggle);
element(rb_directx_nine)->setDisabled(toggle);
}

+ 4
- 0
ui/WBFace.h View File

@@ -26,6 +26,7 @@ protected:

QCheckBox *cb_advanced;
QCheckBox *cb_log;
QCheckBox *cb_directx_off;

QRadioButton *rb_desktop_disable;
QRadioButton *rb_desktop_wine;
@@ -48,9 +49,12 @@ protected:
QGroupBox *group_dxmode;

QLabel *label_args;
QLabel *label_desktop_width;
QLabel *label_desktop_height;

private slots:
void advancedToggle(const bool toggle);
void directxToggle(const bool toggle);
};

#endif // WBFACE_H

+ 3
- 0
ui/WBUiBase.cpp View File

@@ -14,4 +14,7 @@ WBUiBase::WBUiBase(QWidget *parent, QString form, QString icon)
QGridLayout *layout = new QGridLayout;
layout->addWidget(ui);
setLayout(layout);

this->form = form;
this->icon = icon;
}

+ 14
- 0
ui/WBUiBase.h View File

@@ -20,6 +20,20 @@ public:

protected:
QWidget *ui;

template<class C>
C *loadElement(const QString &name){
C *elem = ui->findChild<C*>(name);
if (elem == nullptr)
qDebug() << "Warning:" << typeid(C).name() << name << "is not defined in form" << form;
return elem;
}

private:
QString form;
QString icon;
};

#define element(elem) if (elem) elem

#endif // WBUIBASE_H

+ 6
- 0
wine/Execute.cpp View File

@@ -0,0 +1,6 @@
#include "Execute.h"

Execute::Execute(QObject *parent) : QObject(parent)
{

}

+ 46
- 0
wine/Execute.h View File

@@ -0,0 +1,46 @@
#ifndef EXECUTE_H
#define EXECUTE_H

#include <QObject>
#include <QProcess>

enum eWineDesktop{
WD_disable,
WD_wine,
WD_xephyr
};

enum eWineLog{
WL_disable,
WL_default,
WL_file
};

struct stWineDesktop{
eWineDesktop mode = WD_disable;
union{
struct{
int W;
int H;
};
qint64 display; // PID
};
};

class Execute : public QObject
{
Q_OBJECT
public:
explicit Execute(QObject *parent);

private:
QString winePath;
QString winePrefix;

QStringList args;
QStringList envs;

stWineDesktop desktop;
};

#endif // EXECUTE_H

Loading…
Cancel
Save