Also dann mal los mitm code
login.cpp
Code: Alles auswählen
#include "login.h"
#include "ui_login.h"
#include "ShowWebseite.h"
#include <QPushButton>
#include <QCloseEvent>
LogIn::LogIn(QString Name, QString Version, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::LogIn)
{
ui->setupUi(this);
ui->Titel->setText(Name);
ui->centralWidget->setAutoFillBackground(false);
View_Load = false;
this->setWindowFlags(Qt::FramelessWindowHint);
this->show();
}
LogIn::~LogIn()
{
delete ui;
}
void LogIn::on_Abbrechen_clicked()
{
QApplication::exit();
}
void LogIn::on_Exit_X_clicked()
{
QApplication::exit();
}
void LogIn::on_Minimize_clicked()
{
this->setWindowState(Qt::WindowMinimized);
}
void LogIn::WebView_Destroyed()
{
side->close();
delete side;
this->show();
}
void LogIn::on_Sponsor_L1_linkActivated(const QString &link)
{
this->hide();
side = new ShowWebseite(this,link);
}
void LogIn::mousePressEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
mMoving = true;
mLastMousePosition = event->pos();
}
}
void LogIn::mouseMoveEvent(QMouseEvent* event)
{
if(mMoving)
{
this->move(this->pos() + (event->pos() - mLastMousePosition));
}
}
void LogIn::mouseReleaseEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
mMoving = false;
}
}
main.cpp
Code: Alles auswählen
#include <QtGui/QApplication>
#include <QString>
#include "login.h"
#include "Proxy.cpp"
#include "ShowWebseite.h"
QString Version = "v0.1";
QString Name = "Projekt";
int main(int argc, char *argv[])
{
SetProxy();
QApplication a(argc, argv);
LogIn w(Name, Version);
return a.exec();
}
Proxy.cpp
Code: Alles auswählen
#include <QtNetwork/QNetworkProxy>
#include <QString>
#include <QSettings>
void SetProxy()
{
QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\t4ggno\\SSaver", QSettings::NativeFormat);
QString Hostname = settings.value("Proxy_Hostname").toString();
int Port = settings.value("Proxy_Port").toInt();
QString Name = settings.value("Proxy_Username").toString();
QString Passwort = settings.value("Proxy_Passwort").toString();
QNetworkProxy Proxy;
Proxy.setType(QNetworkProxy::HttpProxy);
Proxy.setHostName(Hostname);
Proxy.setPort(Port);
Proxy.setUser(Name);
Proxy.setPassword(Passwort);
QNetworkProxy::setApplicationProxy(Proxy);
}
ShowWebseite.cpp
Code: Alles auswählen
#include "ShowWebseite.h"
#include "login.h"
#include "ui_ShowWebseite.h"
#include <QString>
#include <QWebView>
#include <QMainWindow>
#include <QCloseEvent>
#include <QMessageBox>
ShowWebseite::ShowWebseite(QMainWindow *parent,QString _Link):
QMainWindow(),
gui_Webseite(new Ui::Webseite)
{
Parent = parent;
Link = _Link;
mMoving = false;
gui_Webseite->setupUi(this);
this->setAutoFillBackground(false);
this->setWindowFlags(Qt::FramelessWindowHint);
this->show();
QObject::connect(gui_Webseite->back,SIGNAL(clicked()),Parent,SLOT(WebView_Destroyed()));
QObject::connect(gui_Webseite->webView,SIGNAL(loadFinished(bool)),this,SLOT(loadError(bool)));
QObject::connect(gui_Webseite->Exit_X,SIGNAL(clicked()),Parent,SLOT(WebView_Destroyed()));
QObject::connect(this,SIGNAL(destroy_Webview()),Parent,SLOT(WebView_Destroyed()));
gui_Webseite->webView->load("http://" + Link);
}
ShowWebseite::~ShowWebseite()
{
delete gui_Webseite;
}
void ShowWebseite::loadError(bool no_error)
{
if(!no_error){
Message = new QMessageBox();
Message->setText("Fehler beim laden der Seite");
Message->setInformativeText("Die Seite konnte nicht geladen werden"
"<br>Verbindungseinstellungen ändern?");
Message->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
int ret = Message->exec();
switch(ret){
case QMessageBox::No:
emit this->destroy_Webview();
}
}
}
void ShowWebseite::mousePressEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
if(event->y() < gui_Webseite->label->height()){
mMoving = true;
mLastMousePosition = event->pos();
}
}
}
void ShowWebseite::mouseMoveEvent(QMouseEvent* event)
{
if(mMoving)
{
this->move(this->pos() + (event->pos() - mLastMousePosition));
}
}
void ShowWebseite::mouseReleaseEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
mMoving = false;
}
}
login.h
Code: Alles auswählen
#ifndef LOGIN_H
#define LOGIN_H
#include "ShowWebseite.h"
#include "ui_login.h"
#include <QMainWindow>
#include <QtWebKit/QWebView>
#include <QString>
class LogIn : public QMainWindow
{
Q_OBJECT
public:
explicit LogIn(QString Titel, QString Version, QWidget *parent = 0);
~LogIn();
bool View_Load;
protected:
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
private slots:
void on_Abbrechen_clicked();
void on_Exit_X_clicked();
void on_Minimize_clicked();
void on_Sponsor_L1_linkActivated(const QString &link);
public slots:
void WebView_Destroyed();
private:
Ui::LogIn *ui;
ShowWebseite *side;
QPoint mLastMousePosition;
bool mMoving;
};
#endif // LOGIN_H
ShowWebseite.h
Code: Alles auswählen
#ifndef SHOWWEBSEITE_H
#define SHOWWEBSEITE_H
#include <QWebView>
#include <QString>
#include <QMainWindow>
#include <QObject>
#include <QPushButton>
#include <QMessageBox>
#include "ui_ShowWebseite.h"
class ShowWebseite : public QMainWindow
{
Q_OBJECT
private:
QMainWindow *Parent;
Ui::Webseite *gui_Webseite;
QPoint mLastMousePosition;
bool mMoving;
QString Link;
QMessageBox *Message;
public:
ShowWebseite(QMainWindow *,QString);
~ShowWebseite();
protected:
void mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
private slots:
void loadError(bool);
signals:
void destroy_Webview();
};
#endif // WEBSEITE_H
login.ui
Code: Alles auswählen
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LogIn</class>
<widget class="QMainWindow" name="LogIn">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>512</width>
<height>297</height>
</rect>
</property>
<property name="windowTitle">
<string>LogIn</string>
</property>
<property name="windowOpacity">
<double>1.000000000000000</double>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QFrame" name="gridFrame">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>451</width>
<height>91</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<family>Arial</family>
<pointsize>15</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Loginname:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Arial</family>
<pointsize>15</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Passwort:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="gridLayoutWidget_2">
<property name="geometry">
<rect>
<x>20</x>
<y>200</y>
<width>291</width>
<height>72</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="Sposoring">
<property name="font">
<font>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Sponsoring</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="Sponsor1">
<property name="text">
<string>Ihre Firma</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="Sponsoring2">
<property name="text">
<string>Ihre Firma</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="Sponsor_L3">
<property name="text">
<string>Ihre URL</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="Sponsoring3">
<property name="text">
<string>Ihre Firma</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="Sponsor_L2">
<property name="text">
<string>Ihre URL</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="Sponsor_L1">
<property name="text">
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="www.t4ggno.com"><span style=" text-decoration: underline; color:#0000ff;">Ihre URL</span></a></p></body></html></string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>460</x>
<y>0</y>
<width>158</width>
<height>35</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QPushButton" name="Minimize">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#222222</string>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Exit_X">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="gridLayoutWidget_3">
<property name="geometry">
<rect>
<x>310</x>
<y>150</y>
<width>201</width>
<height>131</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="Abbrechen">
<property name="text">
<string>Abbrechen</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>50</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Username speichern?</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="Login">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>LogIn</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="PW_Forget">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Passwort vergessen??</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="Registrieren">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Regstrieren</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>461</width>
<height>61</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="Titel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Comic Sans MS</family>
<pointsize>25</pointsize>
<weight>75</weight>
<bold>true</bold>
<underline>true</underline>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:red;</string>
</property>
<property name="text">
<string>TITEL</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>512</width>
<height>21</height>
</rect>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
ShowWebseite.ui
Code: Alles auswählen
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Webseite</class>
<widget class="QMainWindow" name="Webseite">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>546</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{background-color: argb(255,255,255,20)}
QPushButton:hover{background-color:argb(255,255,255,200)}</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="back">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Zurück zum Login</string>
</property>
</widget>
<widget class="QWebView" name="webView">
<property name="geometry">
<rect>
<x>0</x>
<y>20</y>
<width>801</width>
<height>501</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:gray</string>
</property>
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
<property name="renderHints">
<set>QPainter::Antialiasing|QPainter::TextAntialiasing</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>801</width>
<height>21</height>
</rect>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.528, y1:1, x2:0.523, y2:0.192773, stop:0 rgba(0, 0, 88, 255), stop:1 rgba(255, 255, 255, 255));</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>737</x>
<y>0</y>
<width>158</width>
<height>35</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QPushButton" name="Minimize">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#222222</string>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Exit_X">
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
</item>
</layout>
</widget>
<zorder>webView</zorder>
<zorder>back</zorder>
<zorder>label</zorder>
<zorder>horizontalLayoutWidget_2</zorder>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Hoffe jemand kann mir weiter helfen

Außerdem würde ich mich bei tipps freuen (Programmierstiel, einfacherer Quelltext...)
Danke schonmal...