Code cleanup, slots&signals
This commit is contained in:
parent
90fbb80f50
commit
895960c1b0
@ -38,13 +38,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
ui->uploaderList->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
// Add items to uploader selection
|
||||
for (Uploader *u : UploaderSingleton::inst().uploaderList())
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(u->name());
|
||||
item->setToolTip(u->description());
|
||||
ui->uploaderList->addItem(item);
|
||||
if (u->name() == UploaderSingleton::inst().selectedUploader()) item->setSelected(true);
|
||||
}
|
||||
for (Uploader *u : UploaderSingleton::inst().uploaderList()) newUploader(u);
|
||||
connect(&UploaderSingleton::inst(), &UploaderSingleton::newUploader, this, &MainWindow::newUploader);
|
||||
|
||||
// Set filename scheme
|
||||
if ((settings::settings().contains("fileFormat")))
|
||||
@ -85,6 +80,14 @@ void MainWindow::toggleVisible()
|
||||
this->setVisible(!this->isVisible());
|
||||
}
|
||||
|
||||
void MainWindow::newUploader(Uploader *u)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(u->name());
|
||||
item->setToolTip(u->description());
|
||||
ui->uploaderList->addItem(item);
|
||||
if (u->name() == UploaderSingleton::inst().selectedUploader()) item->setSelected(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionQuit_triggered()
|
||||
{
|
||||
quit();
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <QMainWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
#include <uploaders/uploader.hpp>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
@ -15,6 +17,7 @@ class MainWindow : public QMainWindow
|
||||
private slots:
|
||||
void quit();
|
||||
void toggleVisible();
|
||||
void newUploader(Uploader *u);
|
||||
|
||||
void on_actionQuit_triggered();
|
||||
void on_actionFullscreen_triggered();
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <formatter.hpp>
|
||||
#include <settings.hpp>
|
||||
|
||||
UploaderSingleton::UploaderSingleton()
|
||||
UploaderSingleton::UploaderSingleton() : QObject()
|
||||
{
|
||||
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
||||
configDir.mkpath("KShare/uploaders");
|
||||
@ -46,6 +46,7 @@ UploaderSingleton::UploaderSingleton()
|
||||
void UploaderSingleton::registerUploader(Uploader *uploader)
|
||||
{
|
||||
uploaders.insert(uploader->name(), uploader);
|
||||
emit newUploader(uploader);
|
||||
}
|
||||
|
||||
void UploaderSingleton::upload(QPixmap *pixmap)
|
||||
|
@ -4,8 +4,9 @@
|
||||
#include "uploader.hpp"
|
||||
#include <QMap>
|
||||
|
||||
class UploaderSingleton
|
||||
class UploaderSingleton : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static UploaderSingleton &inst()
|
||||
{
|
||||
@ -18,6 +19,8 @@ class UploaderSingleton
|
||||
void set(QString uploader);
|
||||
QString selectedUploader();
|
||||
QList<std::runtime_error> errors();
|
||||
signals:
|
||||
void newUploader(Uploader *u);
|
||||
|
||||
private:
|
||||
UploaderSingleton();
|
||||
|
Loading…
Reference in New Issue
Block a user