Skip to content

Commit a92e904

Browse files
authored
Add files via upload
first commit
1 parent 939891f commit a92e904

30 files changed

+21267
-0
lines changed

source/background.png

50.8 KB
Loading

source/dropgraphicsscene.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <QDebug>
2+
#include <QUrl>
3+
#include "dropgraphicsscene.h"
4+
5+
dropGraphicsScene::dropGraphicsScene(QObject* parent) : QGraphicsScene(parent)
6+
{}
7+
8+
void dropGraphicsScene::dragEnterEvent(QDragEnterEvent *event)
9+
{
10+
event->acceptProposedAction();
11+
}
12+
13+
void dropGraphicsScene::dragMoveEvent(QDragMoveEvent *event)
14+
{
15+
// event->acceptProposedAction();
16+
}
17+
18+
void dropGraphicsScene::dropEvent(QDropEvent *event)
19+
{
20+
21+
const QMimeData* mimeData = event->mimeData();
22+
23+
// check if it is an image file
24+
if (mimeData->hasUrls())
25+
{
26+
clear();
27+
addPixmap(QPixmap(QUrl(mimeData->text()).toLocalFile()).scaled(this->width(), this->height(), Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
28+
event->acceptProposedAction();
29+
}
30+
}
31+
32+
dropGraphicsScene::~dropGraphicsScene()
33+
{}
34+

source/dropgraphicsscene.h

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef _DROPGRAPHICSSCENE_H_
2+
#define _DROPGRAPHICSSCENE_H_
3+
4+
#include <QDragEnterEvent>
5+
#include <QDragMoveEvent>
6+
#include <QDropEvent>
7+
#include <QGraphicsScene>
8+
#include <QMimeData>
9+
10+
class dropGraphicsScene : public QGraphicsScene
11+
{
12+
Q_OBJECT
13+
14+
public:
15+
explicit dropGraphicsScene(QObject *parent = 0);
16+
~dropGraphicsScene();
17+
18+
private:
19+
QGraphicsScene scene;
20+
21+
protected:
22+
void dragEnterEvent(QDragEnterEvent *event);
23+
void dragMoveEvent(QDragMoveEvent *event);
24+
void dropEvent(QDropEvent *event);
25+
26+
protected slots:
27+
28+
public slots:
29+
};
30+
31+
#endif /*_DROPGRAPHICSSCENE_H_*/

source/dropgraphicsview.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <QDebug>
2+
#include <QUrl>
3+
#include "dropgraphicsview.h"
4+
5+
dropGraphicsView::dropGraphicsView(QWidget* parent) : QGraphicsView(parent)
6+
{
7+
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
8+
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
9+
this->setFrameShape(QFrame::Box);
10+
this->setFrameShadow(QFrame::Plain);
11+
this->setScene(&scene);
12+
scene.clear();
13+
scene.addRect(QRect(0, 0, this->width(), this->height()), QPen(Qt::black), QBrush(Qt::SolidPattern));
14+
}
15+
16+
void dropGraphicsView::dragEnterEvent(QDragEnterEvent *event)
17+
{
18+
event->acceptProposedAction();
19+
}
20+
21+
void dropGraphicsView::dragMoveEvent(QDragMoveEvent *event)
22+
{
23+
event->acceptProposedAction();
24+
}
25+
26+
void dropGraphicsView::dropEvent(QDropEvent *event)
27+
{
28+
const QMimeData* mimeData = event->mimeData();
29+
scene.clear();
30+
currentFile = QUrl(mimeData->text()).toLocalFile().trimmed();
31+
scene.addPixmap(QPixmap(currentFile).scaled(this->width()-4, this->height()-4, Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
32+
event->acceptProposedAction();
33+
}
34+
35+
void dropGraphicsView::setImage(QString file)
36+
{
37+
scene.clear();
38+
currentFile = file;
39+
scene.addPixmap(QPixmap(currentFile).scaled(this->width()-4, this->height()-4, Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
40+
}
41+
42+
dropGraphicsView::~dropGraphicsView()
43+
{}
44+

source/dropgraphicsview.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef _DROPGRAPHICSVIEW_H_
2+
#define _DROPGRAPHICSVIEW_H_
3+
4+
#include <QDragEnterEvent>
5+
#include <QDragMoveEvent>
6+
#include <QDropEvent>
7+
#include <QGraphicsView>
8+
#include <QMimeData>
9+
#include "dropgraphicsscene.h"
10+
11+
class dropGraphicsView : public QGraphicsView
12+
{
13+
Q_OBJECT
14+
15+
public:
16+
explicit dropGraphicsView(QWidget *parent = 0);
17+
void setImage(QString file);
18+
QString currentFile;
19+
~dropGraphicsView();
20+
21+
private:
22+
dropGraphicsScene scene;
23+
24+
protected:
25+
void dragEnterEvent(QDragEnterEvent *event);
26+
void dragMoveEvent(QDragMoveEvent *event);
27+
void dropEvent(QDropEvent *event);
28+
29+
protected slots:
30+
31+
public slots:
32+
};
33+
34+
#endif /*_DROPGRAPHICSVIEW_H_*/

source/main.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <QApplication>
2+
#include "qkontrol.h"
3+
4+
int main(int argc, char *argv[])
5+
{
6+
QApplication app(argc, argv);
7+
app.setApplicationName("qKontrol");
8+
app.setWindowIcon(QIcon(":/images/qkontrol.ico"));
9+
qkontrolWindow win;
10+
win.show();
11+
app.setQuitOnLastWindowClosed(true);
12+
13+
return app.exec();
14+
}

source/oscdialog.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <QDialog>
2+
#include <QDir>
3+
#include <QSettings>
4+
#include "oscdialog.h"
5+
6+
oscDialog::oscDialog(QWidget* parent /* = 0 */, Qt::WindowFlags flags /* = 0 */) : QDialog(parent, flags)
7+
{
8+
setupUi(this);
9+
10+
// restore settings from INI file if it exists and update values
11+
if(QFile(QDir::homePath() + "/.qkontrol/osc.ini").exists())
12+
{
13+
QSettings* settings = new QSettings(QDir::homePath() + "/.qkontrol/osc.ini", QSettings::IniFormat);
14+
checkBoxOSC->setChecked(settings->value("enabled").toBool());
15+
hostname->setText(settings->value("hostname").toString());
16+
spinBoxLocalport->setValue(settings->value("local").toInt());
17+
spinBoxRemoteport->setValue(settings->value("remote").toInt());
18+
}
19+
20+
connect(applyButton, SIGNAL(clicked()), this, SLOT(saveAndClose()));
21+
}
22+
23+
// write dialog settings into INI file and close the dialog
24+
void oscDialog::saveAndClose()
25+
{
26+
QSettings* settings = new QSettings(QDir::homePath() + "/.qkontrol/osc.ini", QSettings::IniFormat);
27+
settings->setValue("enabled", checkBoxOSC->isChecked());
28+
settings->setValue("hostname", hostname->text());
29+
settings->setValue("local", spinBoxLocalport->value());
30+
settings->setValue("remote", spinBoxRemoteport->value());
31+
accept();
32+
}
33+
34+
oscDialog::~oscDialog()
35+
{
36+
37+
}
38+

source/oscdialog.h

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef _OSCDIALOG_H_
2+
#define _OSCDIALOG_H_
3+
4+
#include "ui_oscdialog.h"
5+
6+
class oscDialog : public QDialog, public Ui_oscDialog
7+
{
8+
Q_OBJECT
9+
10+
public:
11+
oscDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
12+
~oscDialog();
13+
14+
private:
15+
16+
private slots:
17+
void saveAndClose();
18+
19+
protected slots:
20+
21+
public slots:
22+
};
23+
24+
#endif /*_OSCDIALOG_H_*/

0 commit comments

Comments
 (0)