Remove unused appdatapath class

Reformat some code
This commit is contained in:
Rasmus Karlsson 2018-01-05 02:56:18 +01:00
parent fd8ddcff55
commit 334860dad2
7 changed files with 12 additions and 71 deletions

View file

@ -82,7 +82,6 @@ SOURCES += \
src/messages/messagebuilder.cpp \ src/messages/messagebuilder.cpp \
src/twitch/twitchmessagebuilder.cpp \ src/twitch/twitchmessagebuilder.cpp \
src/widgets/titlebar.cpp \ src/widgets/titlebar.cpp \
src/appdatapath.cpp \
src/singletons/accountmanager.cpp \ src/singletons/accountmanager.cpp \
src/twitch/twitchuser.cpp \ src/twitch/twitchuser.cpp \
src/ircaccount.cpp \ src/ircaccount.cpp \
@ -155,7 +154,6 @@ HEADERS += \
src/messages/messagebuilder.hpp \ src/messages/messagebuilder.hpp \
src/twitch/twitchmessagebuilder.hpp \ src/twitch/twitchmessagebuilder.hpp \
src/widgets/titlebar.hpp \ src/widgets/titlebar.hpp \
src/appdatapath.hpp \
src/singletons/accountmanager.hpp \ src/singletons/accountmanager.hpp \
src/twitch/twitchuser.hpp \ src/twitch/twitchuser.hpp \
src/ircaccount.hpp \ src/ircaccount.hpp \

View file

@ -1,28 +0,0 @@
#include "appdatapath.hpp"
#include <QDebug>
#include <QDir>
#include <QStandardPaths>
QString Path::appdataPath;
std::mutex Path::appdataPathMutex;
const QString &Path::getAppdataPath()
{
std::lock_guard<std::mutex> lock(appdataPathMutex);
if (appdataPath.isEmpty()) {
#ifdef PORTABLE
QString path = QCoreApplication::applicationDirPath();
#else
QString path =
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/Chatterino2/";
#endif
QDir(QDir::root()).mkdir(path);
appdataPath = path;
}
return appdataPath;
}

View file

@ -1,15 +0,0 @@
#pragma once
#include <QString>
#include <mutex>
class Path
{
public:
static const QString &getAppdataPath();
private:
static QString appdataPath;
static std::mutex appdataPathMutex;
};

View file

@ -1,11 +1,7 @@
#include "singletons/settingsmanager.hpp" #include "singletons/settingsmanager.hpp"
#include "appdatapath.hpp"
#include "debug/log.hpp" #include "debug/log.hpp"
#include "singletons/pathmanager.hpp" #include "singletons/pathmanager.hpp"
#include <QDir>
#include <QStandardPaths>
using namespace chatterino::messages; using namespace chatterino::messages;
namespace chatterino { namespace chatterino {

View file

@ -1,14 +1,13 @@
#include "windowmanager.hpp" #include "windowmanager.hpp"
#include "appdatapath.hpp" #include "debug/log.hpp"
#include "singletons/fontmanager.hpp" #include "singletons/fontmanager.hpp"
#include "singletons/thememanager.hpp" #include "singletons/thememanager.hpp"
#include <QDebug> #include <QDebug>
#include <QStandardPaths>
#include <boost/foreach.hpp>
namespace chatterino { namespace chatterino {
namespace singletons { namespace singletons {
WindowManager &WindowManager::getInstance() WindowManager &WindowManager::getInstance()
{ {
static WindowManager instance(ThemeManager::getInstance()); static WindowManager instance(ThemeManager::getInstance());
@ -26,13 +25,6 @@ void WindowManager::initMainWindow()
this->selectedWindow = this->mainWindow = new widgets::Window("main", this->themeManager, true); this->selectedWindow = this->mainWindow = new widgets::Window("main", this->themeManager, true);
} }
static const std::string &getSettingsPath()
{
static std::string path = (Path::getAppdataPath() + "uilayout.json").toStdString();
return path;
}
void WindowManager::layoutVisibleChatWidgets(Channel *channel) void WindowManager::layoutVisibleChatWidgets(Channel *channel)
{ {
this->layout(channel); this->layout(channel);
@ -87,7 +79,7 @@ widgets::Window *WindowManager::windowAt(int index)
if (index < 0 || (size_t)index >= this->windows.size()) { if (index < 0 || (size_t)index >= this->windows.size()) {
return nullptr; return nullptr;
} }
qDebug() << "getting window at bad index" << index; debug::Log("getting window at bad index {}", index);
return this->windows.at(index); return this->windows.at(index);
} }
@ -103,5 +95,5 @@ void WindowManager::save()
} }
} }
} // namespace singletons
} // namespace chatterino } // namespace chatterino
}

View file

@ -14,10 +14,10 @@ class WindowManager
public: public:
static WindowManager &getInstance(); static WindowManager &getInstance();
void initMainWindow();
void layoutVisibleChatWidgets(Channel *channel = nullptr); void layoutVisibleChatWidgets(Channel *channel = nullptr);
void repaintVisibleChatWidgets(Channel *channel = nullptr); void repaintVisibleChatWidgets(Channel *channel = nullptr);
void repaintGifEmotes(); void repaintGifEmotes();
void initMainWindow();
// void updateAll(); // void updateAll();
widgets::Window &getMainWindow(); widgets::Window &getMainWindow();
@ -41,5 +41,5 @@ private:
widgets::Window *selectedWindow = nullptr; widgets::Window *selectedWindow = nullptr;
}; };
} // namespace singletons
} // namespace chatterino } // namespace chatterino
}

View file

@ -261,9 +261,8 @@ QString ChannelView::getSelectedText()
if (first) { if (first) {
first = false; first = false;
bool isSingleWord = bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex <
isSingleMessage && part.getCharacterLength();
this->selection.max.charIndex - charIndex < part.getCharacterLength();
if (isSingleWord) { if (isSingleWord) {
// return single word // return single word
@ -394,7 +393,7 @@ void ChannelView::setChannel(std::shared_ptr<Channel> newChannel)
if (this->scrollBar.isAtBottom()) { if (this->scrollBar.isAtBottom()) {
this->scrollBar.scrollToBottom(); this->scrollBar.scrollToBottom();
} else { } else {
this->scrollBar.offset((qreal)-messages.size()); this->scrollBar.offset((qreal)messages.size());
} }
} }
@ -623,8 +622,7 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
// this->selectionMax.messageIndex >= messageIndex) { // this->selectionMax.messageIndex >= messageIndex) {
// painter.fillRect(buffer->rect(), QColor(24, 55, 25)); // painter.fillRect(buffer->rect(), QColor(24, 55, 25));
//} else { //} else {
painter.fillRect(buffer->rect(), painter.fillRect(buffer->rect(), (messageRef->getMessage()->containsHighlightedPhrase())
(messageRef->getMessage()->containsHighlightedPhrase())
? this->themeManager.messages.backgrounds.highlighted ? this->themeManager.messages.backgrounds.highlighted
: this->themeManager.messages.backgrounds.regular); : this->themeManager.messages.backgrounds.regular);
//} //}